Accessing custom field value through the Design/ Page Templa

Posted by Community Admin on 04-Aug-2018 12:31

Accessing custom field value through the Design/ Page Template

All Replies

Posted by Community Admin on 12-Apr-2017 00:00

Hi all, 

I'm new to Sitefinity, and facing some minor problems with editing Page template.

I've created custom Base template (.master in my VS) as a parent template for all other (Home, About us, etc) and imported it in the Sitefinity Backend. My goal is to add a little bit changed navigation widget, so I've added a custom field of type checkbox to the page template named "ActiveCb" and edited "Vertical with sublevels template" to add my own styling. Trying to access the value of that checkbox gives me the following error:

DataBinding: 'Telerik.Sitefinity.Web.PageSiteNode' does not contain a property with the name 'ActiveCb'.

Here's the code of the navigation widget template I'm adding to my Base page.

 

<%@ 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" %>

<navigation:SitefinitySiteMapDataSource runat="server" ID="dataSource" />


<div class="nav columns-wrap">
    <sf:SitefinityLabel id="title" runat="server" WrapperTagName="h6" HideIfNoText="true" HideIfNoTextMode="Server" />

    <ul runat="server" id="navigationUl">
        <navigation:NavigationContainer ID="NavigationContainer1" runat="server" DataSourceID="dataSource">
            <Templates>
                  <navigation:NavigationTemplate>
                        <Template>
                          
                          <li class="<%# DataBinder.Eval(Container.DataItem,"ActiveCb").ToString().Equals("True")? "active":"none" %>"> 
                                <a id="A1" class="link" runat="server" href='<%# NavigationUtilities.ResolveUrl(Container.DataItem) %>' target='<%# NavigationUtilities.GetLinkTarget(Container.DataItem) %>'><%# Eval("Title") %></a>          
                                <ul id="Ul1" runat="server"></ul>
                            </li> 
                                       
                        </Template>
                      <SelectedTemplate>
                            <li>           
                                <a id="A1" class="link" runat="server" href='<%# NavigationUtilities.ResolveUrl(Container.DataItem) %>' target='<%# NavigationUtilities.GetLinkTarget(Container.DataItem) %>'><%# Eval("Title") %></a>          
                                <ul id="Ul1" runat="server"></ul>
                            </li>                                        
                        </SelectedTemplate>
                    </navigation:NavigationTemplate>
                </Templates>
        </navigation:NavigationContainer>
    </ul>
</div>

 

Seems as thought the PageSiteNode is not aware of this new property. 

Does anyone have an idea how to overcome this problem?

 

Many thanks,

Kris

This thread is closed