PageLayoutCollection.Add Method (String, SPContentTypeId, String)
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, _
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.String
Name of PageLayout.
- associatedContentTypeId
Type: Microsoft.SharePoint.SPContentTypeId
ID of the SPContentType that this PageLayout will be associated with.
- pageMarkup
Type: System.String
ASPX markup for the page layout, or Null 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 | 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 Null. |
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 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.