Address format in widget template
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
>
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
>
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" %>
<%# Eval("Address.City") %>
<%# Eval("Address.Street") %>
By "nothing comes up" I mean the field just shows blank with no data.
However, you're second answer fixed the problem. Thanks!
Hi,
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