Share via


PageLayoutCollection.Add Method (String, SPContentTypeId)

Creates and adds a new PageLayout.

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

Syntax

'Declaration
Public Function Add ( _
    pageLayoutName As String, _
    associatedContentTypeId As SPContentTypeId _
) As PageLayout
'Usage
Dim instance As PageLayoutCollection
Dim pageLayoutName As String
Dim associatedContentTypeId As SPContentTypeId
Dim returnValue As PageLayout

returnValue = instance.Add(pageLayoutName, _
    associatedContentTypeId)
public PageLayout Add(
    string pageLayoutName,
    SPContentTypeId associatedContentTypeId
)

Parameters

Return Value

Type: Microsoft.SharePoint.Publishing.PageLayout
The newly created PageLayout.

Exceptions

Exception Condition
SPException

AssociatedContentTypeId must identify a valid SPContentType on the SPSite.RootWeb site.

PathTooLongException

Specified file or folder name is too long. The URL path for all files and folders must be 260 characters or less (and no more than 128 characters for any single file or folder name in the URL). Please type a shorter file or folder name.

SPException

File with the name "%1" already exists. It was last modified by "%2" on "%3".

SPException

File or folder name "%1" contains characters that are not permitted. Please use a different name.

ArgumentNullException

Indicates that one of the input parameters is a null reference (Nothing in Visual Basic)

UnauthorizedAccessException

Current user does not have sufficient permissions to perform this action.

FileLoadException

Indicates that another file with the same name already exists.

DirectoryNotFoundException

Indicates a problem with the pageLayoutName parameter.

Remarks

The pageLayoutName parameter can either have no file extension or an .aspx extension. The pageLayoutName value must be non-empty and cannot exceed 128 characters. The name must also be unique within the master page gallery of the SPSite.RootWeb site. The pageLayoutName value cannot contain any of the following invalid characters: "#%*:<>?\/{|} or an ampersand or ASCII character 0x7f. The associatedContentTypeId valuemust identify a valid SPContentType on the SPSite.RootWeb site.

See Also

Reference

PageLayoutCollection Class

PageLayoutCollection Members

Add Overload

Microsoft.SharePoint.Publishing Namespace

PageLayout

AssociatedContentType

Add