+1-888-365-2779
Try Now
More in this section

Forums / Designing & Styling / Address format in widget template

Address format in widget template

3 posts, 1 answered
  1. Amanda Shafer
    Amanda Shafer avatar
    198 posts
    Registered:
    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#" />
    </div>
    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" />
    </div>
    It comes in the following format:
    Address
    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
    Registered:
    03 Oct 2016
    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! 

    Regards,
    Peter
    Telerik
     
    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
     
    Answered
  3. Amanda Shafer
    Amanda Shafer avatar
    198 posts
    Registered:
    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!

3 posts, 1 answered