Login

Is it possible to determine if the actual page is in DOPE-mode?

Versions: n/a, FAQ number: 8, Old FAQ number: 962

Q: Is it possible to determine if the actual page is in DOPE-mode (Direct On-Page Editing)?

A: The problem is that there isn't an actual DOPE-mode defined in EPiServer. However it is possible to check if any control on the page is of the type EPiServer.WebControls.Property (or derives from this type) and has the properties EditMode set to false and IsEditable set to true.  That concludes that the control isn't shown in edit-mode, but that it is editable, alas the page is in DOPE-mode.

An example of this is to use the following functions:

 private bool IsDope( ControlCollection controls )
{
   foreach (Control control in controls)
   {
       if ( control.HasControls() && IsDope(control.Controls) )
           return true;

       EPiServer.WebControls.Property prop =
          
control as EPiServer.WebControls.Property;

       if (prop == null)
           continue;
       if (!prop.EditMode && prop.Editable)
           return true;
   }
   return false;
}

private bool IsDope()
{
   return IsDope( Page.Controls );
}

EPiTrace logger