Try Now
More in this section

Forums / Designing & Styling / Address format in widget template

Address format in widget template

4 posts, 1 answered
  1. Amanda Shafer
    Amanda Shafer avatar
    198 posts
    12 Oct 2012
    03 Oct 2014
    Link to this post

    I'm trying to add the address field to a widget template. It is part of the related item section of the template.

    If I use :

    <div class='sfitemAddressWrp'>       
        <sf:SitefinityLabel runat="server" Text='Address:' WrapperTagName="div" HideIfNoText="true" CssClass="sfitemFieldLbl" />     
        <sf:AddressField runat="server" DataFieldName="Address" IsMapExpanded="false" AddressTemplate="#=Street# #=City# #=State# #=Country#" />
    Nothing comes up.

     If I use

    <div class='sfitemShortTxtWrp'>
      <%# (Eval("Address") == null || Eval("Address").Equals(string.Empty)) ? "" : "<b>Address</b>" %>
      <sf:SitefinityLabel runat="server"
      Text='<%# Eval("Address")%>'
      WrapperTagName="div" HideIfNoText="true"
      CssClass="sfitemShortTxt" data-sf-field="Address"
      data-sf-ftype="ShortText" />
    It comes in the following format:
    Street: 1949 Newton Ransom Blvd., City: Clarks Summit, Zip: 18411, CountryCode: US, StateCode: PA, Latitude: , Longitude:

    Is there a way to format the Address so it doesn't include the individual labels?

  2. Peter
    Peter avatar
    36 posts
    30 Jun 2017
    08 Oct 2014
    Link to this post
    Hello Amanda,

    Thank you for using Telerik support. I see two question here:

    1. Why the address field doesn't work
    2. How to control the way the address is displaying with text

    Here are my answers on those:

    1. Your template looks good. Have you added the Address Field's namespace on the top of the template: 
    <%@ Register Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Web.UI.Fields" TagPrefix="sf" %>

    Also, when you say there's nothing, do you mean the whole template disappears (meaning there's an error) or do you mean that it is just the address field that is hidden?

    2. In order to display the individual items, please use code like the one below:
    <%# Eval("Address.City") %>
    <%# Eval("Address.Street") %>

    I hope this helps! 

    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
  3. Amanda Shafer
    Amanda Shafer avatar
    198 posts
    12 Oct 2012
    09 Oct 2014
    Link to this post

    By "nothing comes up" I mean the field just shows blank with no data.

    However, you're second answer fixed the problem. Thanks!

  4. Nilesh
    Nilesh avatar
    0 posts
    19 Dec 2016
    26 Jan
    Link to this post


        Is there any way to display State Code in address field

    <sf:AddressField runat="server" DataFieldName="Address"IsMapExpanded="false" AddressTemplate="#=Street# #=City# #=StateCode# #=Country#" />


    Thanks and Regards

    Nilesh Sharma

4 posts, 1 answered