Detect DOPE mode in codebehind | Episerver Developer Community

Detect DOPE mode in codebehind

Member since: 2006
 

Hello,

I have tried to use code found in FAQ:

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

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

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

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

Except the
EPiServer.Web.WebControls.Property prop = control as EPiServer.Web.WebControls.Property;
replacing older version
EPiServer.Web.WebControls.Property prop = control as EPiServer.Web.WebControls.Property; 
But for every Editable control, for example

result of IsDope is true even though it is not displayed in DOPE mode. 

 

Is there any other way to detect DOPE mode that works?

 

#30070 May 29, 2009 14:44
  • Member since: 2006
     

    Ah I have also tried Emil's

    string dopemode = Request.Params["DopeMode"];
    if (!String.IsNullOrEmpty(dopemode) && dopemode.ToLower() == "enable")
    {
    // DOPE mode detected!
    }

    but the Request.Params collection doesn't contain anything similar to DOPE flag.

     

    :-(

    #30071 May 29, 2009 14:47
  • Member since: 1999
     

     

    bool isDope = ContextMenu.IsMenuEnabled
    && ContextMenu.OnPageEditControl != null
    && ContextMenu.OnPageEditControl.EditMode;

     

     

    #30088 Jun 01, 2009 12:18
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
Please login to post a reply