PageLayoutCollection.Add Method (String, SPContentTypeId, String)
Creates and adds a new PageLayout object.
Namespace: Microsoft.SharePoint.Publishing
Assembly: Microsoft.SharePoint.Publishing (in Microsoft.SharePoint.Publishing.dll)
Syntax
'Declaration
Public Function Add ( _
pageLayoutName As String, _
associatedContentTypeId As SPContentTypeId, _
pageMarkup As String _
) As PageLayout
'Usage
Dim instance As PageLayoutCollection
Dim pageLayoutName As String
Dim associatedContentTypeId As SPContentTypeId
Dim pageMarkup As String
Dim returnValue As PageLayout
returnValue = instance.Add(pageLayoutName, _
associatedContentTypeId, pageMarkup)
public PageLayout Add(
string pageLayoutName,
SPContentTypeId associatedContentTypeId,
string pageMarkup
)
Parameters
pageLayoutName
Type: System.StringName of PageLayout.
associatedContentTypeId
Type: Microsoft.SharePoint.SPContentTypeIdThe identifier (ID) of the SPContentType that this PageLayout will be associated with.
pageMarkup
Type: System.StringASPX markup for the page layout, or a null reference (Nothing in Visual Basic) to indicate that markup from the template page layout should be used.
Return Value
Type: Microsoft.SharePoint.Publishing.PageLayout
The newly created PageLayout object.
Exceptions
Exception | Condition |
---|---|
SPException | AssociatedContentTypeId must identify a valid SPContentType on the SPSite.RootWeb site. |
PathTooLongException | The 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 | The file with the name "%1" already exists. It was last modified by "%2" on "%3". |
SPException | The 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 name extension or an .aspx extension. The pageLayoutName value must not be empty and cannot exceed 128 characters. The name must also be unique within the master page gallery of the SPSite.RootWeb site. The pageLayoutName cannot contain any of the following invalid characters: ", #, %, *, :, <, >, ?, \, /, {, |, } or an ampersand or ASCII character 0x7f. The associatedContentTypeId value must identify a valid SPContentType on the SPSite.RootWeb site.