Detect when the Edit tab in Edit Mode is clicked

Vote:
 

Hi,

I've spent several days searching for a way to detect when the Edit tab (in Edit Mode) is selected. I know that DataFactory contains several methods for catching events, but it doesn't include one for an Edit tab-clicked event.

Is there any way to catch this event and attach an event handler to it?

Thanks!

#52827
Aug 16, 2011 13:32
Vote:
 

What are you looking to ahieve? Is it down at the API level or something in the EPiServer UI?

#52839
Aug 16, 2011 19:08
Vote:
 

I'm making a plugin which, without going into too much detail, should get the name of the editor and the current page id whenever the Edit tab is clicked. It would be preferable if this could be achieved through the API, but other solutions are welcome as well.

#52851
Aug 17, 2011 8:37
Vote:
 

Hello William

You can use the plug in architecture to hook into the edit panel itself (via the LoadComplete event). This fires when the edit panel is being set up so you can get the page ID and editor name here:

[GuiPlugIn(Area = PlugInArea.EditPanel)]
public class EditPanelHook : ICustomPlugInLoader
{
    public PlugInDescriptor[] List()
    {
        // hook LoadComplete-event on EditPanel page
        EditPanel editPanel = HttpContext.Current.Handler as EditPanel;

        if (null != editPanel)
        {
            editPanel.LoadComplete += new EventHandler(editPanel_LoadComplete);
        }

        //Never return a plugin - we don't want to add tabs.
        return new PlugInDescriptor[0] { };
    }

    protected void editPanel_LoadComplete(object sender, EventArgs e)
    {
        //Code to grab the user and page ID here

    }
}

    

 

 

#52855
Aug 17, 2011 13:17
Vote:
 

Thanks! The code works perfectly, had no idea it was so simple :)

#52856
Aug 17, 2011 13:31
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.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.