More in this section

Forums / Developing with Sitefinity / "admin mode" for User Controls

"admin mode" for User Controls

2 posts, 0 answered
  1. UI Crew
    UI Crew avatar
    151 posts
    Registered:
    27 Sep 2012
    20 Aug 2007
    Link to this post
    Hi,

    I have worked out how to display message in a user control while the CMS is in edit mode however I was wondering if there was a way to display a "admin" message in a user control on a page when a person is looking at it in Sitefinity admin.

    For example, I have a public login control which redirects a logged in user who hits the page to the home page of the members area.

    Of course while a person is looking at the page in the CMS interface I don't want that code running and throwing them out of Sitefinity.

    Is there any way my user controls can determine if the user is using the CMS interface and say display a message or stop the code execution.

    Also, can you consider putting Sitefinity publish buttons in a validation group so that they don't try to validate controls in the site web page? (I guess I should put my controls into validation groups too.)

    Thanks

    Seth
  2. Slavo
    Slavo avatar
    295 posts
    Registered:
    24 Sep 2012
    20 Aug 2007
    Link to this post
    Hello Seth Cleaver,

    You can check if the user is viewing the page in edit mode or preview mode in the CMS by checking the QueryString for the value of cmspagemode, like this:

    string mode = Request.QueryString.Get("cmspagemode");  
     
    if (mode != null)  
    {  
        if (mode == "edit" || mode == "preview")  
        {  
            // disable some functionality  
        }  

    If mode is null, then the user is viewing the page outside the admin part of Sitefinity, i.e. a public user.

    If you are asking how to distinguish between viewing the page in public and by clicking Live Site from Sitefinity admin, they are absolutely identical. The Live Site part loads the page in an IFrame, so it is as if viewed in public. You can use JavaScript to check the parent of the window and detect if it is an IFrame or a regular window. In the second case it wouldn't have a parent.
    I hope this helps.

    Kind regards,
    Slavo
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
2 posts, 0 answered