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

Forums / Developing with Sitefinity / Getting a page's root page title

Getting a page's root page title

4 posts, 1 answered
  1. Scott Rozman
    Scott Rozman avatar
    93 posts
    Registered:
    10 Oct 2012
    29 Mar 2010
    Link to this post
    I would like to make a user control to display the title of the page on the root level that it IS or is attached to as a child or sub-child. In other words, every Page A and everything nested under Page A says "Page A".
    Page B and everything nested under Page B says "Page B".

    Page A
        Page AA
             Page AAA
             Page AAB
        Page AB
    Page B
         Page BA
             Page BAA

    Could I get a point in the right direction for the best way to pull out this info?

    Thanks in advance.

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    29 Mar 2010
    Link to this post
    Hi Scott Rozman,

    You can get the pages and their hierarchy directly from the SiteMap. You have to loop recursively through the items and get the parent items that are different from SiteMap.RootNode. You can gather more information at


    Regards,
    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.
  3. Nauman
    Nauman avatar
    35 posts
    Registered:
    28 Jul 2008
    30 Mar 2010
    Link to this post
    Hi Scott

    I am not sure exactly you need this, try this may it will help you

     SiteMapNode SiteMapParentNode;
      protected void TraverseUpNavTree(SiteMapNode node)
        {
            try
            {
                if (node.ParentNode != null && node.ParentNode != SiteMap.RootNode)
                    TraverseUpNavTree(node.ParentNode);
                else
                {
                    SiteMapParentNode= node;
                    return;
                }
            }
            catch { }
        }

    Cheers
    Nauman Ahmed
    Answered
  4. Scott Rozman
    Scott Rozman avatar
    93 posts
    Registered:
    10 Oct 2012
    31 Mar 2010
    Link to this post
    Thanks, Nauman... I've got something working now and took some from you to fix the problem of the ParentNode being Nothing.
    However, I was working in VB.... and it seems that you can't use operators to just compare the nodes as you can in C#, so I had to compare the Url.
    Dim NodeWalker As SiteMapNode
                NodeWalker = SiteMap.CurrentNode
                While ((Not (NodeWalker.ParentNode) Is Nothing) AndAlso (NodeWalker.ParentNode.Url <> SiteMap.RootNode.Url))
                    NodeWalker = NodeWalker.ParentNode
                End While
                lblTopLevel.Text = NodeWalker.Title


Register for webinar
4 posts, 1 answered