Search code examples
c#asp.neteditmodeektron

Is there a way to check if Ektron is loading a page in Edit mode in my codebehind? (C#)


I have a page that prompts the user for a password in order to display the content. However, when Ektron users are editing the page content, I want it to just show the content without asking for the password. The password functionality is all set in the codebehind; the password in the metadata for the page tells the code to hide the usercontrols that show the content (ux.Visible = false) and display the usercontrol that asks for a password. What I'd like to do is check at this point to see whether Ektron is currently in Edit mode, and if so, set ux.Visible = true. Is there a way to check for this?


Solution

  • I found this on the Ektron developer center. [Works with 8.7]

    if (_host != null) // make sure widget is being used inside a PageBuilder page
        {
            var p = this.Page as PageBuilder; // get PageBuilder object
            if (p.Status == Mode.Editing) // check for Editing mode
            {
                 ux.Visible = true //Display UX
            }
        }