PublishingPage.Description Property
Gets or sets descriptive text for this PublishingPage object.
Namespace: Microsoft.SharePoint.Publishing
Assembly: Microsoft.SharePoint.Publishing (in Microsoft.SharePoint.Publishing.dll)
Syntax
'Declaration
Public Property Description As String
Get
Set
'Usage
Dim instance As PublishingPage
Dim value As String
value = instance.Description
instance.Description = value
public string Description { get; set; }
Property Value
Type: System.String
Text that describes this PublishingPage object.
Exceptions
Exception | Condition |
---|---|
[System.ArgumentException] | A property value that is not valid. |
[System.ArgumentNullException] | Indicates that the value being set is a null reference (Nothing in Visual Basic), which is not valid. |
[System.UnauthorizedAccessException] | The current user does not have sufficient permissions to perform this action. |
Remarks
The Description value can be an empty string.
To save changes, you must call the Update after setting this property.
The user must have edit permissions on the PublishingPage to set this value. The user must have view permissions on the PublishingPage to initially retrieve it and get any of its property values.
If this property value is used in HTML that is rendered in a browser, you should HTML-encode the property value to avoid the possibility of scripting attacks.
Examples
This example sets some properties on a PublishingPage object, saves the new values, and publishes the PublishingPage.
Before compiling and running this example, verify that this SPLIstItem is a list item in the pages document library of a PublishingWeb.
This example assumes that the document library that contains the SPListItem requires content approval.
using PublishingPage = Microsoft.SharePoint.Publishing.PublishingPage;
using SPListItem = Microsoft.SharePoint.SPListItem;
using SPFile = Microsoft.SharePoint.SPFile;
using SPModerationStatusType = Microsoft.SharePoint.SPModerationStatusType;
using PublishingWeb = Microsoft.SharePoint.Publishing.PublishingWeb;
using SPUser = Microsoft.SharePoint.SPUser;
using PageLayout = Microsoft.SharePoint.Publishing.PageLayout;
using PublishingPageCollection = Microsoft.SharePoint.Publishing.PublishingPageCollection;
namespace Microsoft.SDK.SharePointServer.Samples
{
public static class PublishingPageCodeSamples
{
public static void SetPagePropertiesAndApprove(SPListItem listItem, SPUser pageContact)
{
// Replace these variable values and input parameters with your own values.
//
// New PublishingPage.Title value
string newTitle = "your Title";
//
// New PublishingPage.Description value
string newDescription = "your Description";
//
// The comment to set when the page is checked in, published, and approved.
string checkInComment = "Your comments";
// Validate the input parameters.
//
if (null == listItem)
{
throw new System.ArgumentNullException("listItem");
}
if (null == pageContact)
{
throw new System.ArgumentNullException("pageContact");
}
// Get the PublishingPage wrapper for the SPListItem that was passed in.
//
PublishingPage publishingPage = null;
if (PublishingPage.IsPublishingPage(listItem))
{
publishingPage = PublishingPage.GetPublishingPage(listItem);
}
else
{
throw new System.ArgumentException("This SPListItem is not a PublishingPage", "listItem");
}
// Check out the page if it is not checked out yet.
//
if (publishingPage.ListItem.File.CheckOutStatus == SPFile.SPCheckOutStatus.None)
{
publishingPage.CheckOut();
}
// Set and save some properties on the PublishingPage.
//
publishingPage.Title = newTitle;
publishingPage.Description = newDescription;
publishingPage.Contact = pageContact;
publishingPage.Update();
// Publish the page, and approve it if required, so that the updated
// values are visible on the published Web site.
//
publishingPage.CheckIn(checkInComment);
SPFile pageFile = publishingPage.ListItem.File;
pageFile.Publish(checkInComment);
pageFile.Approve(checkInComment);
}
}
}
Imports PublishingPage = Microsoft.SharePoint.Publishing.PublishingPage
Imports SPListItem = Microsoft.SharePoint.SPListItem
Imports SPFile = Microsoft.SharePoint.SPFile
Imports SPModerationStatusType = Microsoft.SharePoint.SPModerationStatusType
Imports PublishingWeb = Microsoft.SharePoint.Publishing.PublishingWeb
Imports SPUser = Microsoft.SharePoint.SPUser
Imports PageLayout = Microsoft.SharePoint.Publishing.PageLayout
Imports PublishingPageCollection = Microsoft.SharePoint.Publishing.PublishingPageCollection
Namespace Microsoft.SDK.SharePointServer.Samples
Public NotInheritable Class PublishingPageCodeSamples
Private Sub New()
End Sub
Public Shared Sub SetPagePropertiesAndApprove(ByVal listItem As SPListItem, ByVal pageContact As SPUser)
' Replace these variable values and input parameters with your own values.
'
' New PublishingPage.Title value
Dim newTitle As String = "your Title"
'
' New PublishingPage.Description value
Dim newDescription As String = "your Description"
'
' The comment to set when the page is checked in, published, and approved.
Dim checkInComment As String = "Your comments"
' Validate the input parameters.
'
If Nothing Is listItem Then
Throw New System.ArgumentNullException("listItem")
End If
If Nothing Is pageContact Then
Throw New System.ArgumentNullException("pageContact")
End If
' Get the PublishingPage wrapper for the SPListItem that was passed in.
'
Dim publishingPage As PublishingPage = Nothing
If PublishingPage.IsPublishingPage(listItem) Then
publishingPage = PublishingPage.GetPublishingPage(listItem)
Else
Throw New System.ArgumentException("This SPListItem is not a PublishingPage", "listItem")
End If
' Check out the page if it is not checked out yet.
'
If publishingPage.ListItem.File.CheckOutStatus = SPFile.SPCheckOutStatus.None Then
publishingPage.CheckOut()
End If
' Set and save some properties on the PublishingPage.
'
publishingPage.Title = newTitle
publishingPage.Description = newDescription
publishingPage.Contact = pageContact
publishingPage.Update()
' Publish the page, and approve it if required, so that the updated
' values are visible on the published Web site.
'
publishingPage.CheckIn(checkInComment)
Dim pageFile As SPFile = publishingPage.ListItem.File
pageFile.Publish(checkInComment)
pageFile.Approve(checkInComment)
End Sub
End Class
End Namespace