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

Forums / Developing with Sitefinity / RadTabStrip using sitemapdatasource

RadTabStrip using sitemapdatasource

2 posts, 0 answered
  1. Sheeja
    Sheeja avatar
    1 posts
    Registered:
    29 Sep 2010
    29 Sep 2010
    Link to this post
    Hi,

    In my project I am using RadTabStrip and sitemapdatasource.
    <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" ShowStartingNode="false"
        StartFromCurrentNode="false"  StartingNodeOffset="1"  />
     <telerik:RadTabStrip runat="server" ID="RadTabstrip1" MaxDataBindDepth="2" Skin="" >
         </telerik:RadTabStrip>

    Can you please give me a sample code for building the navigation menu using the SiteMapNodeCollection.
    I am attaching the design of the menu. 

    Any help will be appreciated.Its an urgent requirement.
    Thanks in advance

    Sheeja
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    05 Oct 2010
    Link to this post
    Hello Sheeja,


    The problem in your code is that you are not setting DataSourceID of the RadTabStrip control

    <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" ShowStartingNode="false"
        StartFromCurrentNode="false"   />
     <telerik:RadTabStrip runat="server" DataSourceID="SiteMapDataSource1" ID="RadTabstrip1" MaxDataBindDepth="2" Skin="Vista" >
     </telerik:RadTabStrip>


    Here is a sample code that populates the RadTabStrip control from the SiteMapNode manually

          /// <summary>
        /// Recursively populates the TabStrip with the needed pages (nodes) using pNode as root.
        /// </summary>
        /// <param name="pNode">The root node (later used as the current root node in the recursion).</param>
        /// <param name="levelDepth">The current depth of the tree of tabs.</param>
        private void FillTabStrip(SiteMapNode pNode, RadTabCollection pTabs, int levelDepth)
        {
            int levelPosition = -1;
            foreach (CmsSiteMapNode node in pNode.ChildNodes)
            {
                levelPosition++;
     
                RadTab tab = new RadTab(node.Title);
                tab.NavigateUrl = node.Url;
                pTabs.Add(tab);
                if (node == SiteMap.CurrentNode)
                {
                    tab.Selected = true;
                    tab.Owner.SelectedIndex = levelPosition;
                }
     
                if (levelDepth > this.HierarchyDepth && this.HierarchyDepth != -1)
                    tab.Visible = false;
     
                if (levelDepth == this.HideLevel)
                    tab.Style.Add(HtmlTextWriterStyle.Display, "none");
     
                this.FillTabStrip(node, tab.Tabs, levelDepth + 1);
     
                if (tab.SelectedIndex >= 0)
                    tab.Owner.SelectedIndex = levelPosition;
            }
        }

    You could also take a look at

    I

    Greetings,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
2 posts, 0 answered