How to determine whether the user is in "Customize" or "Edit" mode?

How to determine whether the user is in "Customize" or "Edit" mode?

This question is not answered

Hi,

I am struggling to find a way how to determine whether the user is in "Customize" or "Edit" mode. I need to disable rendering of certain information in my widget when in design mode.

Any help appreciated

Cheers

Joz

Verified Answer
  • Ok. After some time of looking through the properties I have found that I can implement something like the following for the Edit mode:

    /// <summary>

           /// Determines whether the app is in edit mode.

           /// </summary>

           /// <returns>

           ///    <c>true</c> if [is in edit mode]; otherwise, <c>false</c>.

           /// </returns>

           private bool IsInEditMode()

           {

               return !string.IsNullOrEmpty(CSContext.Current.Context.Request.Params["Page-EditMode"]) && CSContext.Current.Context.Request.Params["Page-EditMode"].ToLower() == "true";

           }

    Still need help with how to determine being in "Customize" mode.

    Any ideas?

    Thank you

    Joz

  • In your ContentFragment, override the AddPreviewContentControls method to only render the content you wish to show.

    Alternatively, in your constructor you can specify a different User Control for the preview

    public MyWidget()
    :base("normalUserControl.ascx", "previewUserControl.ascx")
    {
    }
  • Thank you Alex, this seems to be a way to go. :) Still, is there anyway of finding which mode (runtime, Edit or Customize) the code is in? Thank you!

    Joz

  • You can't really tell the difference between edit and customise mode.  As they are essentially the same thing, just different ways of accessing them.

All Replies
  • Ok. After some time of looking through the properties I have found that I can implement something like the following for the Edit mode:

    /// <summary>

           /// Determines whether the app is in edit mode.

           /// </summary>

           /// <returns>

           ///    <c>true</c> if [is in edit mode]; otherwise, <c>false</c>.

           /// </returns>

           private bool IsInEditMode()

           {

               return !string.IsNullOrEmpty(CSContext.Current.Context.Request.Params["Page-EditMode"]) && CSContext.Current.Context.Request.Params["Page-EditMode"].ToLower() == "true";

           }

    Still need help with how to determine being in "Customize" mode.

    Any ideas?

    Thank you

    Joz

  • In your ContentFragment, override the AddPreviewContentControls method to only render the content you wish to show.

    Alternatively, in your constructor you can specify a different User Control for the preview

    public MyWidget()
    :base("normalUserControl.ascx", "previewUserControl.ascx")
    {
    }
  • Thank you Alex, this seems to be a way to go. :) Still, is there anyway of finding which mode (runtime, Edit or Customize) the code is in? Thank you!

    Joz

  • You can't really tell the difference between edit and customise mode.  As they are essentially the same thing, just different ways of accessing them.