WebPartPageMaintenanceMessage Class
Displays a message and corresponding hyperlink indicating that a Web Part Page should be opened in maintenance view to delete problem Web Parts and remove personal settings.
System.Object
System.Web.UI.Control
Microsoft.SharePoint.WebControls.SPControl
Microsoft.SharePoint.WebControls.TemplateBasedControl
Microsoft.SharePoint.WebControls.FormComponent
Microsoft.SharePoint.WebControls.WebPartPageMaintenanceMessage
System.Web.UI.Control
Microsoft.SharePoint.WebControls.SPControl
Microsoft.SharePoint.WebControls.TemplateBasedControl
Microsoft.SharePoint.WebControls.FormComponent
Microsoft.SharePoint.WebControls.WebPartPageMaintenanceMessage
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: No
WebPartPageMaintenanceMessage
Description
The Microsoft.SharePoint.WebControls.WebPartPageMaintenanceMessage sealed class inherits from the Microsoft.SharePoint.WebControls.FormComponent class which is the foundational control for form and field rendering controls. The WebPartPageMaintenanceMessage control is responsible for the rendering of the message and hyperlink displayed to a user when rudimentary problems occur with an arbitrary SPListItem.
First, the WebPartPageMaintenanceMessage will make certain that SPControlMode is accurate. The control is uninterested if the control is in SPControlMode.Display and SPControlMode.New. Following, a SPListItem object is hydrated from the current list item context. The SPBuiltInFieldId.FileLeafRef of the SPListItem, a GUID which represents the server relative URL for the SPListItem.File is checked for a null value along with page type for conformity. If the checks are successful, a HyperLink object is hydrated from a casted WebPartMaintenancePageLink control.
Lastly, the HyperLink.NavigateUrl property is constructed with a constant to _layouts/spcontnt.aspx. Spcontnt is a WebPart page maintenance mode that allows working with problematic WebParts with standard context actions. A representation of this page is callable from the browser by appending ?Contents=1 as a suffixed query string.
The Usage Scenario
You typically find RequiredFieldMessage usage limited to internal calls within SharePoint list related components.
The below shows casting the current instance of a class to a ListFormWebPart then retrieving the ListFormWebPart.ToolBar property to hydrate a ToolBar object. Following, we are testing the context SPControlMode to make certain we are not in display mode, then adding a new WebPartPageMaintenanceMessage control to the RightButtons (RepeatedControls) of the ToolBar object.
C# Code Example
ToolBar toolbar = ((ListFormWebPart)this).Toolbar;
if (!Equals(SPContext.Current.FormContext.FormMode, SPControlMode.Display))
{
WebPartPageMaintenanceMessage wppmm = new WebPartPageMaintenanceMessage ();
toolbar.RightButtons.Controls.Add(wppmm);
}
Visual Basic .NET Code Example
Dim toolbar As ToolBar = DirectCast(Me, ListFormWebPart).Toolbar
If Not Equals(SPContext.Current.FormContext.FormMode, SPControlMode.Display) Then
Dim wppmm As New WebPartPageMaintenanceMessage()
toolbar.RightButtons.Controls.Add(wppmm)
End If
The Microsoft.SharePoint.WebControls.WebPartPageMaintenanceMessage sealed class inherits from the Microsoft.SharePoint.WebControls.FormComponent class which is the foundational control for form and field rendering controls. The WebPartPageMaintenanceMessage control is responsible for the rendering of the message and hyperlink displayed to a user when rudimentary problems occur with an arbitrary SPListItem.
First, the WebPartPageMaintenanceMessage will make certain that SPControlMode is accurate. The control is uninterested if the control is in SPControlMode.Display and SPControlMode.New. Following, a SPListItem object is hydrated from the current list item context. The SPBuiltInFieldId.FileLeafRef of the SPListItem, a GUID which represents the server relative URL for the SPListItem.File is checked for a null value along with page type for conformity. If the checks are successful, a HyperLink object is hydrated from a casted WebPartMaintenancePageLink control.
Lastly, the HyperLink.NavigateUrl property is constructed with a constant to _layouts/spcontnt.aspx. Spcontnt is a WebPart page maintenance mode that allows working with problematic WebParts with standard context actions. A representation of this page is callable from the browser by appending ?Contents=1 as a suffixed query string.
The Usage Scenario
You typically find RequiredFieldMessage usage limited to internal calls within SharePoint list related components.
The below shows casting the current instance of a class to a ListFormWebPart then retrieving the ListFormWebPart.ToolBar property to hydrate a ToolBar object. Following, we are testing the context SPControlMode to make certain we are not in display mode, then adding a new WebPartPageMaintenanceMessage control to the RightButtons (RepeatedControls) of the ToolBar object.
C# Code Example
ToolBar toolbar = ((ListFormWebPart)this).Toolbar;
if (!Equals(SPContext.Current.FormContext.FormMode, SPControlMode.Display))
{
WebPartPageMaintenanceMessage wppmm = new WebPartPageMaintenanceMessage ();
toolbar.RightButtons.Controls.Add(wppmm);
}
Visual Basic .NET Code Example
Dim toolbar As ToolBar = DirectCast(Me, ListFormWebPart).Toolbar
If Not Equals(SPContext.Current.FormContext.FormMode, SPControlMode.Display) Then
Dim wppmm As New WebPartPageMaintenanceMessage()
toolbar.RightButtons.Controls.Add(wppmm)
End If
- 6/3/2010
- Adam Buenz - MVP