More in this section
Forums / General Discussions / DesignMode, cmspagemode=edit, etc.

DesignMode, cmspagemode=edit, etc.

The forums are in read-only mode. In case that you want to directly contact the Progress Sitefinity team use the support center. In our Google Plus group you can find more than one thousand Sitefinity developers discussing different topics. For the Stack Overflow threads don’t forget to use the “Sitefinity” tag.
4 posts, 0 answered
  1. Bob Pinna
    Bob Pinna avatar
    13 posts
    10 Apr 2005
    07 Apr 2009
    Link to this post
    When adding a module custom control to the Sitefinity interface what is the recommended way to:

    1. Detect if the control is being shown on a page via the "View" tab (i.e., the control expects query string arguments at runtime and redirects, want to render dummy data when shown from View).
    2. Detect if the control is being shown on the "edit this page" design surface inside of sitefinity (cmspagemode=edit?).


  2. Georgi
    Georgi avatar
    3583 posts
    28 Oct 2016
    10 Apr 2009
    Link to this post
    Hello Bob Pinna,

    In both cases you might use these approaches:
    Telerik.Cms.Web.CmsPageBase page = this.Page as Telerik.Cms.Web.CmsPageBase;  
    if (page.PageMode != Telerik.Cms.Web.CmsPageMode.Edit)  

    or, you can take the page mode through the query string:
    protected void Page_Load(object sender, EventArgs e)  
           //perform the check.  
           //returns true if it is viewed in administration part.  
        private bool IsPageInAdmin()  
           // will return TRUE is the page is viewed in administration part  
            if (this.Page.Request.QueryString.ToString().IndexOf("cmspagemode=preview") > 0)  
              return true;  
          // will return TRUE is the page is in editing mode  
            if (this.Page.Request.QueryString.ToString().IndexOf("cmspagemode=edit") > 0)  
              return true;  
          // the page is viewed in the public part.  
          return false;  

    All the best,
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
  3. Andreas
    Andreas avatar
    49 posts
    29 Dec 2007
    29 Oct 2009
    Link to this post
    For future reference, in the querystring one, the conditions should be >= 0 (or > -1) since the "cmspagemode=edit" is at position 0 when entering edit mode (or preview mode). Was getting some weird results before I noticed it.
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    12 Sep 2017
    29 Oct 2009
    Link to this post
    Hi Andreas,

    You can also directly use

    HttpContext.Current.Request.QueryString[ "cmspagemode" ] == "edit"

    or checking the mode as shown below:

    string mode = HttpContext.Current.Items["cmspagemode"] as string;
    if(mode == "edit" || mode == "preview")

    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.
Register for webinar
4 posts, 0 answered