More in this section

Forums / Developing with Sitefinity / Custom web editor

Custom web editor

5 posts, 0 answered
  1. James Antrobus
    James Antrobus avatar
    10 posts
    Registered:
    05 Feb 2010
    11 Feb 2010
    Link to this post
    I've created a custom web editor which opens when editing my control - the editor inherits from Telerik.Framework.Web.Design.ControlDesigner.

    How can I access the underlying page? ie. the page I am editing.

    Thanks
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    11 Feb 2010
    Link to this post
    Hello James Antrobus,

    The web editor is used with properties. The WebEditro inherits from WebUITypeEditor. You have created a control designer from your control.

    You can get the current page using the code below

    ICmsUrlContext pageKey = (ICmsUrlContext)this.Context.Items[Telerik.Cms.Web.UrlHelper.CmsPageKey];
               Guid currentPageID = pageKey.PageID;


    Kind 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. James Antrobus
    James Antrobus avatar
    10 posts
    Registered:
    05 Feb 2010
    11 Feb 2010
    Link to this post
    I'm actually in the context of a designer which adds controls to my editor, as far as I understand. The code snippet returns pageKey as null - Context.Items doesn't contain UrlHelper.CmsPageKey.

    My class inherits from Telerik.Framework.Web.Design.ControlDesigner, is it possible to get the current page I'm editing?
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    11 Feb 2010
    Link to this post
    Hi James Antrobus,

    The code snippet returns the current ICms page on which your controls are located.

    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.
  5. James Antrobus
    James Antrobus avatar
    10 posts
    Registered:
    05 Feb 2010
    11 Feb 2010
    Link to this post
    That doesn't seem to work, if I check this.Page.Type I get ASP.sitefinity_admin_ctrlprops_aspx if that helps?

    Update: I've done the following which works. Is there a cleaner way to achieve this?

    var cmsHttpRequest = (CmsHttpRequest)this.Context.Items["CmsHttpRequest"];
    string pageId = cmsHttpRequest.QueryStirng["sfpageid"];
     
    CmsManager manager = new CmsManager();
    IPage page = manager.GetPage(new Guid(pageId));

Register for webinar
5 posts, 0 answered