How to tell if page is in edit mode on a non-publishing site

sharepointsharepoint-2007

For our publishing sites we use the SPContext.Current.FormContext.FormMode enum to work out if the current page is in edit mode. I've seen that this does not work for a team site I'm currently working on. The FormMode is always set to 'Invalid'.

However, when I click edit page on a sample page, the page does switch to edit mode so there must be some other way of knowing that a page is in edit mode. So how can I tell if I'm in edit mode for a page living in a team site?

Cheers.
Jas.

Best Answer

For my scenario, I've found that I can make use of the WebPartManager object to find out if the current page is in edit mode.

Dim wpm As WebPartManager = WebPartManager.GetCurrentWebPartManager(Page)

result = wpm.DisplayMode.Name.Equals("design", StringComparison.InvariantCultureIgnoreCase)

The above code informs me whether the current page is in edit mode, since the webpart zone is in design mode. When not in design mode, the DisplayMode will usually be 'Browse'.

Related Topic