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

Forums / General Discussions / Determine CMSPageMode in MasterPage

Determine CMSPageMode in MasterPage

4 posts, 0 answered
  1. Armysniper
    Armysniper avatar
    126 posts
    Registered:
    03 Mar 2005
    23 Jul 2010
    Link to this post
    In my controls I typically use:
    CmsPageBase cmsPage = this.Page as CmsPageBase;
    if (cmsPage.PageMode == CmsPageMode.Live)
    {
    ...
    }

     

    How can I reproduce this in a Master Page? I have code in a master page that I am using that wont run properly in the CMS's admin pages. I need the ability to shunt it for template management.

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    25 Jul 2010
    Link to this post
    Hi Armysniper,

    You can use the QueryString key

    if(HttpContext.Current.Request.QueryString[ "cmspagemode"] == preview
        {
          
        }


    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. Armysniper
    Armysniper avatar
    126 posts
    Registered:
    03 Mar 2005
    08 Aug 2010
    Link to this post
    That does not work if you are trying to edit the template. I tried changing it to this but it also did not work...

    if (HttpContext.Current.Request.QueryString["cmspagemode"] != "preview" || HttpContext.Current.Request.QueryString["cmspagemode"] != "edit")

    Any ideas?
  4. Armysniper
    Armysniper avatar
    126 posts
    Registered:
    03 Mar 2005
    08 Aug 2010
    Link to this post
    This was the way I ended up solving it...this covered preview and edit mode...

    if (HttpContext.Current.Request.QueryString["cmspagemode"] != "preview" && HttpContext.Current.Request.QueryString["cmspagemode"] != "edit")
Register for webinar
4 posts, 0 answered