C# Class Microsoft.SharePoint.Client.PageExtensions

Class that handles all page and web part related operations
Show file Open project: OfficeDev/PnP-Sites-Core

Public Methods

Method Description
AddHtmlToWikiPage ( this web, string serverRelativePageUrl, string html ) : void

Add HTML to a wiki page

AddHtmlToWikiPage ( this web, string folder, string html, string page ) : void

Add html to a wiki style page

AddHtmlToWikiPage ( this web, string folder, string html, string page, int row, int col ) : void

Add a HTML fragment to a location on a wiki style page

AddLayoutToWikiPage ( this web, WikiPageLayout layout, string serverRelativePageUrl ) : void

Applies a layout to a wiki page

AddLayoutToWikiPage ( this web, string folder, WikiPageLayout layout, string page ) : void

Applies a layout to a wiki page

AddNavigationFriendlyUrl ( this page, Web web, string navigationTitle, string friendlyUrlSegment, NavigationTermSetItem editableParent, bool showInGlobalNavigation = true, bool showInCurrentNavigation = true ) : string

Adds a user-friendly URL for a PublishingPage object.

AddPublishingPage ( this web, string pageName, string pageTemplateName, string title = null, bool publish = false, Folder folder = null, System.DateTime startDate = null, System.DateTime endDate = null, System.Boolean schedule = false ) : void

Adds the publishing page.

AddWebPartToWebPartPage ( this web, OfficeDevPnP.Core.Entities.WebPartEntity webPart, string page ) : WebPartDefinition

Inserts a web part on a web part page

AddWebPartToWebPartPage ( this web, string serverRelativePageUrl, OfficeDevPnP.Core.Entities.WebPartEntity webPart ) : WebPartDefinition

Inserts a web part on a web part page

AddWebPartToWikiPage ( this web, string folder, OfficeDevPnP.Core.Entities.WebPartEntity webPart, string page, int row, int col, bool addSpace ) : WebPartDefinition

Add web part to a wiki style page

AddWikiPage ( this web, string wikiPageLibraryName, string wikiPageName ) : string

Adds a blank Wiki page to the site pages library

AddWikiPageByUrl ( this web, string serverRelativePageUrl, string html = null ) : void

Adds a wiki page by Url

DeleteWebPart ( this web, string serverRelativePageUrl, string title ) : void

Deletes a web part from a page

DeleteWebPart ( this web, string folder, string title, string page ) : void

Deletes a web part from a page

EnsureWikiPage ( this web, string wikiPageLibraryName, string wikiPageName ) : string

Returns the Url for the requested wiki page, creates it if the pageis not yet available

GetPublishingPage ( this web, string fileLeafRef ) : PublishingPage

Gets a Publishing Page from the root folder of the Pages library.

GetPublishingPage ( this web, string fileLeafRef, Folder folder ) : PublishingPage

Gets a Publishing Page from any folder in the Pages library.

GetWebPartProperties ( this web, System.Guid id, string serverRelativePageUrl ) : PropertyValues

Returns web part properties

GetWebPartXml ( this web, System.Guid webPartId, string serverRelativePageUrl ) : string
GetWebParts ( this web, string serverRelativePageUrl ) : IEnumerable

List the web parts on a page

GetWikiPageContent ( this web, string serverRelativePageUrl ) : string

Returns the HTML contents of a wiki page

SetWebPartProperty ( this web, string key, bool value, System.Guid id, string serverRelativePageUrl ) : void

Sets a web part property

SetWebPartProperty ( this web, string key, int value, System.Guid id, string serverRelativePageUrl ) : void

Sets a web part property

SetWebPartProperty ( this web, string key, string value, System.Guid id, string serverRelativePageUrl ) : void

Sets a web part property

Private Methods

Method Description
AddHtmlToWikiPage ( this web, string serverRelativePageUrl, string html, int row, int col ) : void
AddWebPart ( File webPartPage, OfficeDevPnP.Core.Entities.WebPartEntity webPart, string zoneId, int zoneIndex ) : WebPartDefinition
AddWebPartToWikiPage ( this web, string serverRelativePageUrl, OfficeDevPnP.Core.Entities.WebPartEntity webPart, int row, int col, bool addSpace ) : WebPartDefinition
SetWebPartPropertyInternal ( this web, string key, object value, System.Guid id, string serverRelativePageUrl ) : void
WikiPageImplementation ( Web web, string wikiPageLibraryName, string wikiPageName, string &wikiPageUrl, List &pageLibrary, string &newWikiPageUrl, File &currentPageFile, string &pathAndQuery ) : void

Method Details

AddHtmlToWikiPage() public static method

Add HTML to a wiki page
Thrown when serverRelativePageUrl or html is a zero-length string or contains only white space Thrown when serverRelativePageUrl or html is null
public static AddHtmlToWikiPage ( this web, string serverRelativePageUrl, string html ) : void
web this Site to be processed - can be root web or sub site
serverRelativePageUrl string
html string
return void

AddHtmlToWikiPage() public static method

Add html to a wiki style page
Thrown when folder, html or page is a zero-length string or contains only white space Thrown when folder, html or page is null
public static AddHtmlToWikiPage ( this web, string folder, string html, string page ) : void
web this Site to be processed - can be root web or sub site
folder string System name of the wiki page library - typically sitepages
html string The html to insert
page string Page to add the html on
return void

AddHtmlToWikiPage() public static method

Add a HTML fragment to a location on a wiki style page
Thrown when folder, html or page is a zero-length string or contains only white space Thrown when folder, html or page is null
public static AddHtmlToWikiPage ( this web, string folder, string html, string page, int row, int col ) : void
web this Site to be processed - can be root web or sub site
folder string System name of the wiki page library - typically sitepages
html string html to be inserted
page string Page to add the web part on
row int Row of the wiki table that should hold the inserted web part
col int Column of the wiki table that should hold the inserted web part
return void

AddLayoutToWikiPage() public static method

Applies a layout to a wiki page
Thrown when serverRelativePageUrl is a zero-length string or contains only white space Thrown when serverRelativePageUrl is null
public static AddLayoutToWikiPage ( this web, WikiPageLayout layout, string serverRelativePageUrl ) : void
web this Site to be processed - can be root web or sub site
layout WikiPageLayout Wiki page layout to be applied
serverRelativePageUrl string
return void

AddLayoutToWikiPage() public static method

Applies a layout to a wiki page
Thrown when folder or page is a zero-length string or contains only white space Thrown when folder or page is null
public static AddLayoutToWikiPage ( this web, string folder, WikiPageLayout layout, string page ) : void
web this Site to be processed - can be root web or sub site
folder string System name of the wiki page library - typically sitepages
layout WikiPageLayout Wiki page layout to be applied
page string Name of the page that will get a new wiki page layout
return void

AddNavigationFriendlyUrl() public static method

Adds a user-friendly URL for a PublishingPage object.
public static AddNavigationFriendlyUrl ( this page, Web web, string navigationTitle, string friendlyUrlSegment, NavigationTermSetItem editableParent, bool showInGlobalNavigation = true, bool showInCurrentNavigation = true ) : string
page this The target page to add to managed navigation.
web Web The target web.
navigationTitle string The title for the navigation item.
friendlyUrlSegment string The user-friendly text to use as the URL segment.
editableParent NavigationTermSetItem The parent NavigationTermSetItem object below which this new friendly URL should be created.
showInGlobalNavigation bool Defines whether the navigation item has to be shown in the Global Navigation, optional and default to true.
showInCurrentNavigation bool Defines whether the navigation item has to be shown in the Current Navigation, optional and default to true.
return string

AddPublishingPage() public static method

Adds the publishing page.
Thrown when key or pageName is a zero-length string or contains only white space Thrown when key or pageName is null
public static AddPublishingPage ( this web, string pageName, string pageTemplateName, string title = null, bool publish = false, Folder folder = null, System.DateTime startDate = null, System.DateTime endDate = null, System.Boolean schedule = false ) : void
web this The web.
pageName string Name of the page.
pageTemplateName string Name of the page template/layout excluded the .aspx file extension.
title string The title of the target publishing page.
publish bool Should the page be published or not?
folder Folder The target folder for the page, within the Pages library.
startDate System.DateTime Start date for scheduled publishing.
endDate System.DateTime End date for scheduled publishing.
schedule System.Boolean Defines whether to define a schedule or not.
return void

AddWebPartToWebPartPage() public static method

Inserts a web part on a web part page
Thrown when page is a zero-length string or contains only white space Thrown when webPart or page is null
public static AddWebPartToWebPartPage ( this web, OfficeDevPnP.Core.Entities.WebPartEntity webPart, string page ) : WebPartDefinition
web this Site to be processed - can be root web or sub site
webPart OfficeDevPnP.Core.Entities.WebPartEntity Information about the web part to insert
page string Page to add the web part on
return WebPartDefinition

AddWebPartToWebPartPage() public static method

Inserts a web part on a web part page
Thrown when serverRelativePageUrl is a zero-length string or contains only white space Thrown when serverRelativePageUrl or webPart is null
public static AddWebPartToWebPartPage ( this web, string serverRelativePageUrl, OfficeDevPnP.Core.Entities.WebPartEntity webPart ) : WebPartDefinition
web this Site to be processed - can be root web or sub site
serverRelativePageUrl string Page to add the web part on
webPart OfficeDevPnP.Core.Entities.WebPartEntity Information about the web part to insert
return WebPartDefinition

AddWebPartToWikiPage() public static method

Add web part to a wiki style page
Thrown when folder or page is a zero-length string or contains only white space Thrown when folder, webPart or page is null
public static AddWebPartToWikiPage ( this web, string folder, OfficeDevPnP.Core.Entities.WebPartEntity webPart, string page, int row, int col, bool addSpace ) : WebPartDefinition
web this Site to be processed - can be root web or sub site
folder string System name of the wiki page library - typically sitepages
webPart OfficeDevPnP.Core.Entities.WebPartEntity Information about the web part to insert
page string Page to add the web part on
row int Row of the wiki table that should hold the inserted web part
col int Column of the wiki table that should hold the inserted web part
addSpace bool Does a blank line need to be added after the web part (to space web parts)
return WebPartDefinition

AddWikiPage() public static method

Adds a blank Wiki page to the site pages library
Thrown when wikiPageLibraryName or wikiPageName is a zero-length string or contains only white space Thrown when wikiPageLibraryName or wikiPageName is null
public static AddWikiPage ( this web, string wikiPageLibraryName, string wikiPageName ) : string
web this Site to be processed - can be root web or sub site
wikiPageLibraryName string Name of the wiki page library
wikiPageName string Wiki page to operate on
return string

AddWikiPageByUrl() public static method

Adds a wiki page by Url
Thrown when serverRelativePageUrl is a zero-length string or contains only white space Thrown when serverRelativePageUrl is null
public static AddWikiPageByUrl ( this web, string serverRelativePageUrl, string html = null ) : void
web this The web to process
serverRelativePageUrl string Server relative URL of the wiki page to process
html string HTML to add to wiki page
return void

DeleteWebPart() public static method

Deletes a web part from a page
Thrown when serverRelativePageUrl or title is a zero-length string or contains only white space Thrown when serverRelativePageUrl or title is null
public static DeleteWebPart ( this web, string serverRelativePageUrl, string title ) : void
web this Site to be processed - can be root web or sub site
serverRelativePageUrl string Server relative URL of the page to remove
title string Title of the web part that needs to be deleted
return void

DeleteWebPart() public static method

Deletes a web part from a page
Thrown when folder, title or page is a zero-length string or contains only white space Thrown when folder, title or page is null
public static DeleteWebPart ( this web, string folder, string title, string page ) : void
web this Site to be processed - can be root web or sub site
folder string System name of the wiki page library - typically sitepages
title string Title of the web part that needs to be deleted
page string Page to remove the web part from
return void

EnsureWikiPage() public static method

Returns the Url for the requested wiki page, creates it if the pageis not yet available
Thrown when wikiPageLibraryName or wikiPageName is a zero-length string or contains only white space Thrown when wikiPageLibraryName or wikiPageName is null
public static EnsureWikiPage ( this web, string wikiPageLibraryName, string wikiPageName ) : string
web this Site to be processed - can be root web or sub site
wikiPageLibraryName string Name of the wiki page library
wikiPageName string Wiki page to operate on
return string

GetPublishingPage() public static method

Gets a Publishing Page from the root folder of the Pages library.
fileLeafRef fileLeafRef
public static GetPublishingPage ( this web, string fileLeafRef ) : PublishingPage
web this The web.
fileLeafRef string The file leaf reference.
return PublishingPage

GetPublishingPage() public static method

Gets a Publishing Page from any folder in the Pages library.
fileLeafRef fileLeafRef
public static GetPublishingPage ( this web, string fileLeafRef, Folder folder ) : PublishingPage
web this The web.
fileLeafRef string The file leaf reference.
folder Folder The folder where to search the page.
return PublishingPage

GetWebPartProperties() public static method

Returns web part properties
Thrown when key or serverRelativePageUrl is a zero-length string or contains only white space Thrown when key or serverRelativePageUrl is null
public static GetWebPartProperties ( this web, System.Guid id, string serverRelativePageUrl ) : PropertyValues
web this The web to process
id System.Guid The id of the webpart
serverRelativePageUrl string
return PropertyValues

GetWebPartXml() public static method

public static GetWebPartXml ( this web, System.Guid webPartId, string serverRelativePageUrl ) : string
web this
webPartId System.Guid
serverRelativePageUrl string
return string

GetWebParts() public static method

List the web parts on a page
Thrown when serverRelativePageUrl is a zero-length string or contains only white space Thrown when serverRelativePageUrl is null
public static GetWebParts ( this web, string serverRelativePageUrl ) : IEnumerable
web this Site to be processed - can be root web or sub site
serverRelativePageUrl string Server relative url of the page containing the webparts
return IEnumerable

GetWikiPageContent() public static method

Returns the HTML contents of a wiki page
Thrown when serverRelativePageUrl is a zero-length string or contains only white space Thrown when serverRelativePageUrl is null
public static GetWikiPageContent ( this web, string serverRelativePageUrl ) : string
web this Site to be processed - can be root web or sub site
serverRelativePageUrl string Server relative url of the page, e.g. /sites/demo/SitePages/Test.aspx
return string

SetWebPartProperty() public static method

Sets a web part property
Thrown when key or serverRelativePageUrl is a zero-length string or contains only white space Thrown when key or serverRelativePageUrl is null
public static SetWebPartProperty ( this web, string key, bool value, System.Guid id, string serverRelativePageUrl ) : void
web this The web to process
key string The key to update
value bool The value to set
id System.Guid The id of the webpart
serverRelativePageUrl string
return void

SetWebPartProperty() public static method

Sets a web part property
Thrown when key or serverRelativePageUrl is a zero-length string or contains only white space Thrown when key or serverRelativePageUrl is null
public static SetWebPartProperty ( this web, string key, int value, System.Guid id, string serverRelativePageUrl ) : void
web this The web to process
key string The key to update
value int The value to set
id System.Guid The id of the webpart
serverRelativePageUrl string
return void

SetWebPartProperty() public static method

Sets a web part property
Thrown when key or serverRelativePageUrl is a zero-length string or contains only white space Thrown when key or serverRelativePageUrl is null
public static SetWebPartProperty ( this web, string key, string value, System.Guid id, string serverRelativePageUrl ) : void
web this The web to process
key string The key to update
value string The value to set
id System.Guid The id of the webpart
serverRelativePageUrl string
return void