More in this section

Forums / Developing with Sitefinity / SitefinitySiteMap and RadPanelbar issue with empty nodes

SitefinitySiteMap and RadPanelbar issue with empty nodes

3 posts, 0 answered
  1. Daniel Plomp
    Daniel Plomp avatar
    952 posts
    Registered:
    18 Feb 2004
    14 Oct 2011
    Link to this post
    Hi all,

    I've created a custom usercontrol for displaying a sidemenu.
    I've used a SiteMapDataSource (based on the SitefinitySiteMap) and a default RadPanelbar.

    When I don't have any subpages, it still renders 3 empty <li> tags. What are those things and how to get rid of them?

    This is my code:

    Subnavigation.ascx

    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Subnavigation.ascx.cs"
        Inherits="SitefinityWebApp.Custom.General.Subnavigation" %>
    <%@ Register Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Web.UI"
        TagPrefix="sf" %>
    <telerik:RadPanelBar ID="sideNavigation" runat="server" EnableEmbeddedBaseStylesheet="false"
        EnableEmbeddedSkins="false" DataSourceID="sfDatasource" Skin="EexSidebar">
    </telerik:RadPanelBar>
    <asp:SiteMapDataSource ID="sfDatasource" runat="server" SiteMapProvider="SitefinitySiteMap"
        ShowStartingNode="false" StartFromCurrentNode="false" StartingNodeOffset="1" />

    Subnavigation.ascx.cs
    public partial class Subnavigation : System.Web.UI.UserControl {
     
            protected void Page_Load(object sender, EventArgs e) {
     
                this.sideNavigation.ItemDataBound += new RadPanelBarEventHandler(sideNavigation_ItemDataBound);
            }
     
            void sideNavigation_ItemDataBound(object sender, RadPanelBarEventArgs e) {
     
                var item = e.Item.DataItem as PageSiteNode;
                if (!item.ShowInNavigation)
                    e.Item.Visible = false;
            }
        }

    It renders the following output:
    <div id="ctl00_ContentSidebar_T4181E1D7007_sideNavigation" class="RadPanelBar RadPanelBar_EexSidebar">
    <ul class="rpRootGroup">
    <li class="rpItem rpFirst"></li>
    <li class="rpItem"></li>
    <li class="rpItem rpLast"></li>
    </ul>
    </div>

    But... there are no childnodes for the current page.

    What is the problem here?

    Regards,
    Daniel
  2. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    14 Oct 2011
    Link to this post
    Try this instead

    <sitefinity:SitefinitySiteMapDataSource ID="sfDatasource" runat="server" ShowStartingNode="false" />

    And comment out all your code-behind databound code

    It should have better performance and handle the Show In Navigation by itself.
  3. Daniel Plomp
    Daniel Plomp avatar
    952 posts
    Registered:
    18 Feb 2004
    14 Oct 2011
    Link to this post
    Thanks, give it a try. -Daniel-
3 posts, 0 answered