This topic has not yet been rated - Rate this topic

PageModeIndicator Class

Represents a page mode indicator control indicating whether the Web Part page is in personal mode or shared mode.

System.Object
  System.Web.UI.Control
    System.Web.UI.WebControls.WebControl
      Microsoft.SharePoint.WebControls.PageModeIndicator

Namespace:  Microsoft.SharePoint.WebControls
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: No
[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public sealed class PageModeIndicator : WebControl
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
PageModeIndicator
Description

The Microsoft.SharePoint.WebControls.PageModeIndicator sealed class inherits from System.Web.UI.WebControls.WebControl. The principal objective of the PageModeIndicator WebControl is tailored around maintenance and investigative reasons for WebPartPage state. 

You can see this control in action when you place a WebPartPage into Edit Mode (appending the URL suffix ?PageView=Shared).

The output from PageModeIndicator is the conditional rendering of three strings to standard output:

PageModeVersion – This is always the text “Version:” suffixed with the current page mode. A characteristic string return would be “you are editing the Shared Version of this page”.

PersonalizationScope.User – Write out a string if the WebPartManager.Personalization.Scope is User

Personalization.Shared – Write out a string if The WebPartManager.Personalization.Scope is Shared

First, PageModeIndicator will use the System.Web.UI.Page to hydrate a System.Web.UI.WebControls.WebParts.WebPartManager object. Following, all the relevant properties required are available off the WebPartManager object.

The Usage Scenario

The prime usage of PageModeIndicator is evident when heavily using personalization services and WebPartPages heavily reliant on end user editing. In such cases, it is imperative to keep users informed current page state. Internally, this control is employed when placing a WebPartPage into Edit Mode.

In the below, we are instantiating a new PageModeIndicator object, and then adding it to the control collection, as would be customary in a custom WebPart.

C# Code Example 

protected override void CreateChildControls()
{
PageModeIndicator indicator = new PageModeIndicator();
Controls.Add(indicator);
}

Visual Basic .NET Code Example

Protected Overloads Overrides Sub CreateChildControls()
Dim indicator As New PageModeIndicator()
Controls.Add(indicator)
End Sub