More in this section

Forums / Developing with Sitefinity / Find the PageID of a page which does not appear in the site navigation

Find the PageID of a page which does not appear in the site navigation

2 posts, 0 answered
  1. Andrew
    Andrew avatar
    6 posts
    Registered:
    26 Jul 2007
    07 Aug 2007
    Link to this post
    Hello

    I have to find the PageID of a page which does not appear in the navigation. (from an entirely different page)

    I cannot use the SiteMap for this as it only loads pages which do appear in the navigation. Any suggestions?


  2. Slavo
    Slavo avatar
    295 posts
    Registered:
    24 Sep 2012
    08 Aug 2007
    Link to this post
    Hello Andrew,

    You are right: the Sitemap does not return pages which are not shown in navigation. Since you want to find the ID from a different page, I assume you want to do it by URL. If you know the URL of the page you want, then you can use the UrlHelper class in Telerik.Cms.Web namespace. It has a method called GetUrl() that returns an ICmsUrlContext object. Here is the code I used to display the ID of a page with url "~/notshown.aspx":

    string pageURL = this.ResolveUrl("~/bg/notshown.aspx");  
    ICmsUrlContext context = UrlHelper.GetUrl(pageURL);  
     
    this.sampleText.Text = context.PageID.ToString(); 

    Here, sampleText is just a Label control.

    All the best,
    Slavo
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
2 posts, 0 answered