Compartilhar via


PageLayout.Description propriedade

Obtém ou define o texto descritivo para o objeto PageLayout .

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

Sintaxe

'Declaração
Public Property Description As String
    Get
    Set
'Uso
Dim instance As PageLayout
Dim value As String

value = instance.Description

instance.Description = value
public string Description { get; set; }

Valor de propriedade

Tipo: System.String
O texto que descreve este objeto PageLayout .
O valor de Description pode ser uma seqüência vazia. Um valor de uma referência nula (Nothing no Visual Basic) será tratado também como uma seqüência vazia.

Exceções

Exceção Condição
ArgumentException

Um valor de propriedade não é válido.

UnauthorizedAccessException

O usuário atual não tem permissões suficientes para executar esta ação.

Comentários

Você deve chamar Update depois de definir esta propriedade para salvar as alterações.

O usuário deve ter permissões de edição no objeto PageLayout para definir este valor. O usuário deve ter permissões de exibição no objeto PageLayout para recuperá-lo inicialmente e para obter qualquer um dos seus valores de propriedade.

Se o valor dessa propriedade é usada em HTML e é processado em um navegador da Web, você deve codificar o valor da propriedade para evitar a possibilidade de ataques de script.

Exemplos

Antes de compilar e executar esse exemplo, verifique se o objeto de SPListItem um item de lista para um layout de página que reside na Galeria de páginas mestras no site de nível superior.

Este exemplo assume que a Galeria de páginas mestras que contém o objeto SPListItem requer aprovação de conteúdo.

using PageLayout = Microsoft.SharePoint.Publishing.PageLayout;
using SPListItem = Microsoft.SharePoint.SPListItem;
using SPFile = Microsoft.SharePoint.SPFile;

namespace Microsoft.SDK.SharePointServer.Samples
{
    public static class PageLayoutCodeSamples
    {
        // This method sets some properties on a PageLayout object,
        // saves the new values, and publishes the PageLayout.
        public static void SetPageLayoutPropertiesAndApprove(SPListItem layoutListItem)
        {
            // Replace these variable values and input
            // parameters with your own values.
            // New PageLayout.Title value
            string newTitle = "your Title";
            // New PageLayout.Description value
            string newDescription = "your Description";
            // The comment to set when the layout is checked in,
            // published, and approved.
            string checkInComment = "your comments";
            // Validate the input parameters.
            if (null == layoutListItem)
            {
                throw new System.ArgumentNullException("layoutListItem");
            }

            // Get the PageLayout wrapper for the SPListItem
            // that is passed in.
            PageLayout pageLayout = new PageLayout(layoutListItem);

            // Check out the PageLayout if it is not checked out yet.
            if (pageLayout.ListItem.File.CheckOutStatus == 
              SPFile.SPCheckOutStatus.None)
            {
                pageLayout.ListItem.File.CheckOut();
            }

            // Set and save some properties on the PageLayout.
            pageLayout.Title = newTitle;
            pageLayout.Description = newDescription;
            pageLayout.Update();

            // Publish the PageLayout and Approve it so that the
            // updated values are available on the published Web site.
            pageLayout.ListItem.File.CheckIn(checkInComment);
            SPFile layoutFile = pageLayout.ListItem.File;
            layoutFile.Publish(checkInComment);
            layoutFile.Approve(checkInComment);

        }
    }
}
Imports PageLayout = Microsoft.SharePoint.Publishing.PageLayout
Imports SPListItem = Microsoft.SharePoint.SPListItem
Imports SPFile = Microsoft.SharePoint.SPFile

Namespace Microsoft.SDK.SharePointServer.Samples
    Public NotInheritable Class PageLayoutCodeSamples
        ' This method sets some properties on a PageLayout object,
        ' saves the new values, and publishes the PageLayout.
        Private Sub New()
        End Sub
        Public Shared Sub SetPageLayoutPropertiesAndApprove(ByVal layoutListItem As SPListItem)
            ' Replace these variable values and input
            ' parameters with your own values.
            ' New PageLayout.Title value
            Dim newTitle As String = "your Title"
            ' New PageLayout.Description value
            Dim newDescription As String = "your Description"
            ' The comment to set when the layout is checked in,
            ' published, and approved.
            Dim checkInComment As String = "your comments"
            ' Validate the input parameters.
            If Nothing Is layoutListItem Then
                Throw New System.ArgumentNullException("layoutListItem")
            End If

            ' Get the PageLayout wrapper for the SPListItem
            ' that is passed in.
            Dim pageLayout As New PageLayout(layoutListItem)

            ' Check out the PageLayout if it is not checked out yet.
            If pageLayout.ListItem.File.CheckOutStatus = SPFile.SPCheckOutStatus.None Then
                pageLayout.ListItem.File.CheckOut()
            End If

            ' Set and save some properties on the PageLayout.
            pageLayout.Title = newTitle
            pageLayout.Description = newDescription
            pageLayout.Update()

            ' Publish the PageLayout and Approve it so that the
            ' updated values are available on the published Web site.
            pageLayout.ListItem.File.CheckIn(checkInComment)
            Dim layoutFile As SPFile = pageLayout.ListItem.File
            layoutFile.Publish(checkInComment)
            layoutFile.Approve(checkInComment)

        End Sub
    End Class
End Namespace

Ver também

Referência

PageLayout classe

PageLayout membros

Microsoft.SharePoint.Publishing namespace