SharePoint 2013: How can I tell if my page is in edit mode?

The solution lies in the object model: Microsoft.SharePoint.SPContext.Current.FormContext.FormMode
It returns a SPControlMode enumeration.

An example usage of the code is as follows:

if (Microsoft.SharePoint.SPContext.Current.FormContext.FormMode == SPControlMode.Display)
{
  // Do display stuff
}
else if ( Microsoft.SharePoint.SPContext.Current.FormContext.FormMode = SPControlMode.Edit )
{
  // Do edit stuff
}

Comments

Popular posts from this blog

SharePoint 2013: Error updating managed account credentials

How can I call a JIRA api through Powershell?