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

Forums / Developing with Sitefinity / Is page being view via CMS Admin

Is page being view via CMS Admin

7 posts, 0 answered
  1. Mike
    Mike avatar
    221 posts
    Registered:
    19 Aug 2008
    13 Jan 2009
    Link to this post
    Is there a way to know if the current page is being viewed throught he CSM Administration pages? I have some pages that require a certain flow to happen before the function correctly... On the live website this works, within the CMS administration this flow does not exisit and the pages error because the require certain data...

    What i would like to do is catch if the page/control is being view throught he CMS and display a warning within the control so that the layout of the control can still be worked ina nd the the control can be managed without error.

    Duncan
  2. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    Registered:
    18 Jul 2012
    13 Jan 2009
    Link to this post
    I had asked about this before, and I cannot seem to locate my thread in the form. this is the code I was given to use for an admin check:

     

    private bool IsPageInAdmin()
    {
    // will return TRUE is the page is viewed in administration part
    if (this.Page.Request.RawUrl.IndexOf("cmspagemode=preview") > 0)
    return true;

    // will return TRUE is the page is in editing mode
    if (this.Page.Request.RawUrl.IndexOf("cmspagemode=edit") > 0)
    return true;

     

     

    // the page is viewed in the public part.
    return false;
    }

    hope this was helpful! by the way what happened to the code paster tool for this thing?

     

  3. Mike
    Mike avatar
    221 posts
    Registered:
    19 Aug 2008
    14 Jan 2009
    Link to this post
    Thanks again Sel,

    This does the trick.... I modified it slightly to read:

    if (HttpContext.Current.Request.RawUrl.Contains("cmspagemode=preview"))
    return true;

    ..etc...

    Thanks,

    Duncan
  4. Pepi
    Pepi avatar
    981 posts
    Registered:
    28 Oct 2016
    14 Jan 2009
    Link to this post
    Hello Duncan,

    Here is another approach to check this:

    private bool IsPageInAdmin() 
        { 
            Telerik.Cms.Web.CmsPageBase page = (Telerik.Cms.Web.CmsPageBase)this.Page; 
            if (page.PageMode != Telerik.Cms.Web.CmsPageMode.Preview) 
                return true;   
            ... 
        } 

    Hope this helps.

    Greetings,
    Pepi
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  5. Mike
    Mike avatar
    221 posts
    Registered:
    19 Aug 2008
    14 Jan 2009
    Link to this post
    Thanks Pepi,

    That's what i was looking for.... the API call....

    Duncan
  6. Mike
    Mike avatar
    221 posts
    Registered:
    19 Aug 2008
    15 Jan 2009
    Link to this post
    Hi Pepi,

    I'm having a hell of a time converting this.Page to CmsPageBase... I am doing this from a class that inherits System.Web.UI.Page...

    Am i missing something here?

    Duncan
  7. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    19 Jan 2009
    Link to this post
    Hi Duncan,

    The problem is that you are inheriting from System.Web.UI.Page. This way, there is no way to convert the page to CmsPage.
    If you place Pepi's code in a user control, it will be fine because it will be running in the CMS context.


    Best wishes,
    Georgi
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Register for webinar
7 posts, 0 answered