PublishingPage.Contact property

Gets or sets the user who currently owns this PublishingPage object.

Namespace:  Microsoft.SharePoint.Publishing
Assembly:  Microsoft.SharePoint.Publishing (in Microsoft.SharePoint.Publishing.dll)

Public Property Contact As SPUser
Dim instance As PublishingPage
Dim value As SPUser

value = instance.Contact

instance.Contact = value

Property value

Type: Microsoft.SharePoint.SPUser
The SPUser object that represents the user who currently owns this PublishingPage


the current user does not have sufficient permissions to perform this action.

The Contact property is the preferred property for tracking a SPUser who owns a PublishingPage. However, if you do not specify a Contact value, then the LocalContactName, LocalContactEmail, and LocalContactImage properties provide user information that is specific to this PublishingPage. These values are relevant only for the specified PublishingPage and have no effect on any SPUser objects on the site.

The Contact property is mutually exclusive of the LocalContactName, LocalContactEmail, and LocalContactImage properties. Setting the LocalContactName, LocalContactE-mail, or LocalContactImage properties to a value that is not empty and not null clears the Contact property. Similarly, setting the Contact property to a value that is not null clears the LocalContactName, LocalContactE-mail, and LocalContactImage properties.

You can set the Contact value to a null reference (Nothing in Visual Basic).

To save changes after setting the Contact property, you must call the Update method.

To set this value, the user must have both View and Edit permissions on the PublishingPage., View permissions to retrieve the page and to return its property values, and Edit permissions to change the value.

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.

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)
                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
            End If

            ' Set and save some properties on the PublishingPage.
            publishingPage.Title = newTitle
            publishingPage.Description = newDescription
            publishingPage.Contact = pageContact

            ' Publish the page, and approve it if required, so that the updated 
            ' values are visible on the published Web site.
            Dim pageFile As SPFile = publishingPage.ListItem.File
        End Sub
    End Class
End Namespace