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

Forums / Designing with Sitefinity / SiteMenu ItemTemplate not pulling Description

SiteMenu ItemTemplate not pulling Description

4 posts, 0 answered
  1. ColinBowern
    ColinBowern avatar
    20 posts
    Registered:
    12 Aug 2012
    29 Aug 2008
    Link to this post

    I'm trying to pull the description from the site node and it appears that it isn't being bound to the CmsSiteMapNode.  Is there any other way to grab the page description field?

    <radM:RadMenu ID="RadMenu1" runat="server" DataSourceID="SitemapDataSource1" OnItemDataBound="RadMenu1_ItemDataBound" Skin="None">  
        <ItemTemplate> 
            <href="<%# Eval("Url") %>"><%#Eval("Title")%><br /> 
                <span><%# Eval("Description")%></span></a> 
        </ItemTemplate> 
    </radM:RadMenu> 

  2. Pepi
    Pepi avatar
    981 posts
    Registered:
    08 Dec 2016
    01 Sep 2008
    Link to this post
    Hello Colin,

    A possible solution is to implement the required functionality in the RadMenu1_ItemDataBound event handler. Here is a simple example:

    .ascx
    <asp:SiteMapDataSource ID="SitemapDataSource1" runat="server" ShowStartingNode="false" /> 
    <radM:RadMenu ID="RadMenu1" runat="server" DataSourceID="SitemapDataSource1" OnItemDataBound="RadMenu1_ItemDataBound" Skin="None"
    </radM:RadMenu> 

    .ascx.cs
    public void RadMenu1_ItemDataBound(object sender, RadMenuEventArgs e) 
        { 
            CmsSiteMapNode cmsNode = e.Item.DataItem as CmsSiteMapNode; 
            if (cmsNode != null
            { 
                e.Item.Text = e.Item.Text + "<br/>" + cmsNode.CmsPage.Description; 
            } 
     
            ... 
        } 

    Do let us know if you need any further assistance.

    Sincerely yours,
    Pepi
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Zahid Ali
    Zahid Ali avatar
    47 posts
    Registered:
    16 Nov 2009
    03 Jan 2010
    Link to this post
    Hello,

    How to use Item template and be able to add description too?

    The solutions suggested by Pepi, doesn't work with ItemTemplate.

    thanks.

    Zahid
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    04 Jan 2010
    Link to this post
    Hello Zahid Ali,

    If you use RadMenu templates you have to access the controls in the template ans set desired text  - in your case CmsPage description.

    RadMenuItem item = RadMenu1.FindItemByText("AboutUs");
    Label lbl = (Label)item .FindControl("Label1");
    if(lbl !=null)
    {
     lbl.text = lbl.text + cmsNode.CmsPage.Description;
    }

    Regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Register for webinar
4 posts, 0 answered