Compartilhar via


PublishingService.CreatePageLayout Method

Creates a new PageLayout object.

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

Syntax

'Declaration
<WebMethodAttribute> _
Public Function CreatePageLayout ( _
    pageLayoutName As String, _
    associatedContentTypeId As String, _
    title As String, _
    description As String, _
    siteUrl As String _
) As String
'Usage
Dim instance As PublishingService
Dim pageLayoutName As String
Dim associatedContentTypeId As String
Dim title As String
Dim description As String
Dim siteUrl As String
Dim returnValue As String

returnValue = instance.CreatePageLayout(pageLayoutName, _
    associatedContentTypeId, title, _
    description, siteUrl)
[WebMethodAttribute]
public string CreatePageLayout(
    string pageLayoutName,
    string associatedContentTypeId,
    string title,
    string description,
    string siteUrl
)

Parameters

  • pageLayoutName
    Type: System.String

    File name of the new page layout. It must have an .aspx extension. It should not include the path to the file.

  • associatedContentTypeId
    Type: System.String

    Associated content type ID string.

  • title
    Type: System.String

    Optional string value specifying the title of the page layout. This parameter may be a null reference (Nothing in Visual Basic).

  • description
    Type: System.String

    Optional string value specifying the description of the page layout. This parameter may be a null reference (Nothing in Visual Basic).

  • siteUrl
    Type: System.String

    Absolute URL of the site. The page layout is created in the page layout gallery on the root Web of the specified site.

Return Value

Type: System.String
A string containing the absolute URL of the new PageLayout object.

Examples

using System;
using System.Net;
using PublishingServiceUtility.PublishingWebService;

namespace PublishingServiceUtility
{
    public class Program
    {

        internal static void CreatePressReleasePageLayout()
        {
            // Add a Web reference to the Web service located at "http://<yourserver>/<yoursite>/_vti_bin/PublishingService.asmx"
            // using the name PublishingWebService and Visual Studio to generate the PublishingService proxy object.

            // Create and initialize the PublishingService proxy object.
            PublishingService publishingService = new PublishingService();
            publishingService.Url = "http://<yourserver>/<yoursite>/_vti_bin/PublishingService.asmx";
            publishingService.AllowAutoRedirect = false;

            // This sample uses the credentials of the current user. If you want to use the credentials of a different user
            // then create a new NetworkCredential instance and use that instead of the DefaultCredentials used here.
            publishingService.Credentials = CredentialCache.DefaultCredentials;

            // Create the press release page layout.
            publishingService.CreatePageLayout("PressReleaseSmallImage.aspx",
                "0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900242457EFB8B24247815D688C526CD44D",
                "Press Release with Small Image", "This page layout is for press releases that need a small image at the top",
                "http://<yourserver>/<yoursite>");
        }

        public static void Main(string[] arguments)
        {
            CreatePressReleasePageLayout();
        }

    } // class Program

See Also

Reference

PublishingService Class

PublishingService Members

Microsoft.SharePoint.Publishing.WebServices Namespace

PublishingService