Top-parent pagenode of current page

Posted by Community Admin on 05-Aug-2018 10:20

Top-parent pagenode of current page

All Replies

Posted by Community Admin on 15-Mar-2011 00:00

Hi,

How can I obtain the "top-parent" / "top-root" of the actual page?

Posted by Community Admin on 15-Mar-2011 00:00

Hello ,

You can use while loop to get the top level parent

var actualNode = SiteMapBase.GetActualCurrentNode();
while (actualNode.ParentNode != null)
    actualNode = actualNode.ParentNode as PageSiteNode;
 


Kind regards,
Ivan Dimitrov
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!

Posted by Community Admin on 10-Dec-2012 00:00


using
Telerik.Sitefinity.Web;
 
 
 
 
namespace SitefinityWebApp.UserControls
    public partial class SubNaviTitle : System.Web.UI.UserControl
    
        protected void Page_Load(object sender, EventArgs e)
        
            var actualNode = SiteMapBase.GetActualCurrentNode();
            while (actualNode.ParentNode != null && actualNode.ParentNode.Title != "Pages")
            
                actualNode = actualNode.ParentNode as PageSiteNode;
 
            
                     Label1.Text = actualNode.Title;
        
    

I had the problem that Ivans Code returned 'Pages¨avbove changes fixed that for me.

Same for 

        Label1.Text =  SiteMapBase.GetActualCurrentNode().RootNode.Title

Which would be the shortest version, but also returns Pages.

Markus

This thread is closed