More in this section

Forums / Developing with Sitefinity / Finding the current page on PagePropertiesInsert.ascx

Finding the current page on PagePropertiesInsert.ascx

2 posts, 0 answered
  1. Anthony Smith
    Anthony Smith avatar
    34 posts
    Registered:
    08 Dec 2009
    14 Dec 2009
    Link to this post

    Hi
    I'm currently using "page editing template" (i.e. PagePropertiesInsert.ascx) to run some custom code i.e. the plan is to add a feature where we can set custom properties per page.

    In doing so i'm finding the current page via the following code:

    Dim siteMapPanel As UI.SiteMapPanel = DirectCast(Me.Page.Controls(0).Controls(1).FindControl("ContentPlaceHolder1").FindControl("siteMap"), UI.SiteMapPanel)
               

    However unfortunately finding the current page via this logic does not work when you choose a page to edit from anywhere other than the left hand navigation of sitefinity (e.g. if you click all pages, and edit a page from the grid view for example).

    Can you please advice what i'm doing wrong here or if there is better way to find the current editing page of sf?

    Thanks
    Anthony

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    14 Dec 2009
    Link to this post
    Hello Anthony Smith,

    Below is the code that you can use to get the page that is being edited

    protected override void OnPreRender(EventArgs e)
     {
         base.OnPreRender(e);
         Guid pageID = ((Telerik.Cms.Web.UI.PageEditor)(this.Parent.Parent.Parent.Parent.Parent.Parent)).SelectedPageId;
    }
     
    Greetings,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
2 posts, 0 answered