Bind custom fields in widget templates
You can bind simple properties, like Integer, Boolean, or Lstring fields, in templates using the Eval statement. Helper methods in the NavigationUtilities class are provided in order to show links of Related data and media items.
Use the following example to bind a custom field in a widget template:
ASP.NET
<%@ Control Language="C#" %>
<%@ Import Namespace="Telerik.Sitefinity.Web.UI.NavigationControls.Extensions.LightNavigationControlTemplate" %>
<%@ Import Namespace="Telerik.Sitefinity.Web.UI.NavigationControls" %>
<%@ Register Assembly="Telerik.Sitefinity" TagPrefix="navigation" Namespace="Telerik.Sitefinity.Web.UI.NavigationControls" %>
<%@ Register Assembly="Telerik.Sitefinity" TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI" %>
<sf:ResourceLinks ID="resourcesLinks2" runat="server" UseEmbeddedThemes="true" Theme="Basic">
<sf:ResourceFile Name="Telerik.Sitefinity.Resources.Themes.Basic.Styles.nav.widget.css" Static="true" />
</sf:ResourceLinks>
<navigation:SitefinitySiteMapDataSource runat="server" ID="dataSource" />
<sf:SitefinityLabel ID="title" runat="server" WrapperTagName="div" HideIfNoText="true" HideIfNoTextMode="Server" />
<div class="sfNavWrp sfNavHorizontalWrp <%= this.GetCssClass() %> <%= this.GetType() %>">
<%-- responsive design section - renders templates for the responsive design--%>
<navigation:NavTransformationTemplate runat="server" TransformationName="ToToggleMenu" TemplateName="ToggleMenu" />
<navigation:NavTransformationTemplate runat="server" TransformationName="ToDropDown" TemplateName="Dropdown" />
<%--end of the responsive design section --%>
<ul class="sfNavHorizontal sfNavList">
<navigation:NavigationContainer runat="server" DataSourceID="dataSource">
<Templates>
<navigation:NavigationTemplate>
<Template>
<li>
<a runat="server" href='<%# NavigationUtilities.ResolveUrl(Container.DataItem) %>' target='<%# NavigationUtilities.GetLinkTarget(Container.DataItem) %>'><%# Eval("Title") %></a>
<%--------------------------------- samples start -------------------------------------%>
<%--basic properties --%>
<div><%# Eval("Hint") %></div>
<%--urls to related data --%>
<img src='<%#NavigationUtilities.GetRelatedMediaLink(Container.DataItem, "HelpImage", "thumb80")%>' />
<%--urls to related data --%>
<a runat="server" href='<%# NavigationUtilities.GetRelatedDataItemLink(Container.DataItem, "Article") %>' target='<%# NavigationUtilities.GetLinkTarget(Container.DataItem) %>'>News Item</a>
<%--------------------------------- samples end ----------------------------------------%>
</li>
</Template>
<SelectedTemplate>
<li>
<a runat="server" class="sfSel" href='<%# NavigationUtilities.ResolveUrl(Container.DataItem) %>' target='<%# NavigationUtilities.GetLinkTarget(Container.DataItem, "HelpImage") %>'><%# Eval("Title") %></a>
</li>
</SelectedTemplate>
</navigation:NavigationTemplate>
</Templates>
</navigation:NavigationContainer>
</ul>
</div>
Want to learn more?
Enhance your Sitefinity skills by enrolling in free training sessions. Become Sitefinity certified through Progress Education Community to strengthen your professional credentials.
Get started with Integration Hub | Sitefinity Cloud
This free lesson teaches administrators, marketers, and other business professionals how to use Sitefinity Integration Hub to create automated workflows between Sitefinity and other business systems.
Web Security for Sitefinity Administrators
This free lesson teaches administrators the basics about protecting your Sitefinity instance and your sites from external threats. Configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.
Foundations of Sitefinity ASP.NET Core Development
The free on-demand video course teaches developers how to use Sitefinity ASP.NET Core and take advantage of its decoupled architecture and modern development model.