Class PageExtensions
Class that handles all page and web part related operations
Inheritance
Namespace: Microsoft.SharePoint.Client
Assembly: PnP.Framework.dll
Syntax
public static class PageExtensions : object
Methods
AddClientSidePage(Web, String, Boolean)
Adds a client side "modern" page to a "classic" or "modern" site
Declaration
public static IPage AddClientSidePage(this Web web, string pageName = "", bool alreadyPersist = false)
Parameters
Web
web
Web to add the page to |
System. Name (e.g. demo.aspx) of the page to be added |
System. Already persist the created, empty, page before returning the instantiated Client |
Returns
IPage
A Client |
AddClientSidePageAsync(Web, String, Boolean)
Adds a client side "modern" page to a "classic" or "modern" site
Declaration
public static async Task<IPage> AddClientSidePageAsync(this Web web, string pageName = "", bool alreadyPersist = false)
Parameters
Web
web
Web to add the page to |
System. Name (e.g. demo.aspx) of the page to be added |
System. Already persist the created, empty, page before returning the instantiated Client |
Returns
Task<IPage>
A Client |
AddHtmlToWikiPage(Web, String, String)
Add HTML to a wiki page
Declaration
public static void AddHtmlToWikiPage(this Web web, string serverRelativePageUrl, string html)
Parameters
Web
web
Site to be processed - can be root web or sub site |
System. Server relative URL of the page to add html to |
System.
|
AddHtmlToWikiPage(Web, String, String, Int32, Int32)
Add a HTML fragment to a location on a wiki style page
Declaration
public static void AddHtmlToWikiPage(this Web web, string serverRelativePageUrl, string html, int row, int col)
Parameters
Web
web
Site to be processed - can be root web or sub site |
System. server relative Url of the page to add the fragment to |
System. html to be inserted |
System. Row of the wiki table that should hold the inserted web part |
System. Column of the wiki table that should hold the inserted web part |
AddHtmlToWikiPage(Web, String, String, String)
Add html to a wiki style page
Declaration
public static void AddHtmlToWikiPage(this Web web, string folder, string html, string page)
Parameters
Web
web
Site to be processed - can be root web or sub site |
System. System name of the wiki page library - typically sitepages |
System. The html to insert |
System. Page to add the html on |
AddHtmlToWikiPage(Web, String, String, String, Int32, Int32)
Add a HTML fragment to a location on a wiki style page
Declaration
public static void AddHtmlToWikiPage(this Web web, string folder, string html, string page, int row, int col)
Parameters
Web
web
Site to be processed - can be root web or sub site |
System. System name of the wiki page library - typically sitepages |
System. html to be inserted |
System. Page to add the web part on |
System. Row of the wiki table that should hold the inserted web part |
System. Column of the wiki table that should hold the inserted web part |
AddLayoutToWikiPage(Web, WikiPageLayout, String)
Applies a layout to a wiki page
Declaration
public static void AddLayoutToWikiPage(this Web web, WikiPageLayout layout, string serverRelativePageUrl)
Parameters
Web
web
Site to be processed - can be root web or sub site |
Wiki Wiki page layout to be applied |
System. Server relative URL of the page to add the layout to |
AddLayoutToWikiPage(Web, String, WikiPageLayout, String)
Applies a layout to a wiki page
Declaration
public static void AddLayoutToWikiPage(this Web web, string folder, WikiPageLayout layout, string page)
Parameters
Web
web
Site to be processed - can be root web or sub site |
System. System name of the wiki page library - typically sitepages |
Wiki Wiki page layout to be applied |
System. Name of the page that will get a new wiki page layout |
AddNavigationFriendlyUrl(PublishingPage, Web, String, String, NavigationTermSetItem, Boolean, Boolean)
Adds a user-friendly URL for a PublishingPage object.
Declaration
public static string AddNavigationFriendlyUrl(this PublishingPage page, Web web, string navigationTitle, string friendlyUrlSegment, NavigationTermSetItem editableParent, bool showInGlobalNavigation = true, bool showInCurrentNavigation = true)
Parameters
Publishing The target page to add to managed navigation. |
Web
web
The target web. |
System. The title for the navigation item. |
System. The user-friendly text to use as the URL segment. |
Navigation The parent NavigationTermSetItem object below which this new friendly URL should be created. |
System. Defines whether the navigation item has to be shown in the Global Navigation, optional and default to true. |
System. Defines whether the navigation item has to be shown in the Current Navigation, optional and default to true. |
Returns
System. The simple link URL just created. |
AddWebPartToWebPartPage(Web, WebPartEntity, String)
Inserts a web part on a web part page
Declaration
public static WebPartDefinition AddWebPartToWebPartPage(this Web web, WebPartEntity webPart, string page)
Parameters
Web
web
Site to be processed - can be root web or sub site |
Web Information about the web part to insert |
System. Page to add the web part on |
Returns
Web Returns the added |
AddWebPartToWebPartPage(Web, String, WebPartEntity)
Inserts a web part on a web part page
Declaration
public static WebPartDefinition AddWebPartToWebPartPage(this Web web, string serverRelativePageUrl, WebPartEntity webPart)
Parameters
Web
web
Site to be processed - can be root web or sub site |
System. Page to add the web part on |
Web Information about the web part to insert |
Returns
Web Returns the added |
AddWebPartToWikiPage(Web, String, WebPartEntity, Int32, Int32, Boolean)
Add web part to a wiki style page
Declaration
public static WebPartDefinition AddWebPartToWikiPage(this Web web, string serverRelativePageUrl, WebPartEntity webPart, int row, int col, bool addSpace)
Parameters
Web
web
Site to be processed - can be root web or sub site |
System. Server relative URL of the page to add the webpart to |
Web Information about the web part to insert |
System. Row of the wiki table that should hold the inserted web part |
System. Column of the wiki table that should hold the inserted web part |
System. Does a blank line need to be added after the web part (to space web parts) |
Returns
Web Returns the added |
AddWebPartToWikiPage(Web, String, WebPartEntity, String, Int32, Int32, Boolean)
Add web part to a wiki style page
Declaration
public static WebPartDefinition AddWebPartToWikiPage(this Web web, string folder, WebPartEntity webPart, string page, int row, int col, bool addSpace)
Parameters
Web
web
Site to be processed - can be root web or sub site |
System. System name of the wiki page library - typically sitepages |
Web Information about the web part to insert |
System. Page to add the web part on |
System. Row of the wiki table that should hold the inserted web part |
System. Column of the wiki table that should hold the inserted web part |
System. Does a blank line need to be added after the web part (to space web parts) |
Returns
Web Returns the added |
AddWikiPage(Web, String, String)
Adds a blank Wiki page to the site pages library
Declaration
public static string AddWikiPage(this Web web, string wikiPageLibraryName, string wikiPageName)
Parameters
Web
web
Site to be processed - can be root web or sub site |
System. Name of the wiki page library |
System. Wiki page to operate on |
Returns
System. The relative URL of the added wiki page |
AddWikiPageByUrl(Web, String, String)
Adds a wiki page by Url
Declaration
public static void AddWikiPageByUrl(this Web web, string serverRelativePageUrl, string html = null)
Parameters
Web
web
The web to process |
System. Server relative URL of the wiki page to process |
System. HTML to add to wiki page |
DeleteWebPart(Web, String, String)
Deletes a web part from a page
Declaration
public static void DeleteWebPart(this Web web, string serverRelativePageUrl, string title)
Parameters
Web
web
Site to be processed - can be root web or sub site |
System. Server relative URL of the page to remove |
System. Title of the web part that needs to be deleted |
DeleteWebPart(Web, String, String, String)
Deletes a web part from a page
Declaration
public static void DeleteWebPart(this Web web, string folder, string title, string page)
Parameters
Web
web
Site to be processed - can be root web or sub site |
System. System name of the wiki page library - typically sitepages |
System. Title of the web part that needs to be deleted |
System. Page to remove the web part from |
EnsureWikiPage(Web, String, String)
Returns the Url for the requested wiki page, creates it if the pageis not yet available
Declaration
public static string EnsureWikiPage(this Web web, string wikiPageLibraryName, string wikiPageName)
Parameters
Web
web
Site to be processed - can be root web or sub site |
System. Name of the wiki page library |
System. Wiki page to operate on |
Returns
System. The relative URL of the added wiki page |
GetWebPartProperties(Web, Guid, String)
Returns web part properties
Declaration
public static PropertyValues GetWebPartProperties(this Web web, Guid id, string serverRelativePageUrl)
Parameters
Web
web
The web to process |
Guid
id
The id of the webpart |
System.
|
Returns
Property
|
GetWebParts(Web, String)
List the web parts on a page
Declaration
public static IEnumerable<WebPartDefinition> GetWebParts(this Web web, string serverRelativePageUrl)
Parameters
Web
web
Site to be processed - can be root web or sub site |
System. Server relative URL of the page containing the webparts |
Returns
IEnumerable<Web
|
GetWebPartXml(Web, Guid, String)
Gets XML string of a Webpart
Declaration
public static string GetWebPartXml(this Web web, Guid webPartId, string serverRelativePageUrl)
Parameters
Web
web
Site to be processed - can be root web or sub site |
Guid
webPartId
The id of the webpart |
System. Server relative URL of the page to add the xml to |
Returns
System. Returns XML string of a Webpart |
GetWikiPageContent(Web, String)
Gets the HTML contents of a wiki page
Declaration
public static string GetWikiPageContent(this Web web, string serverRelativePageUrl)
Parameters
Web
web
Site to be processed - can be root web or sub site |
System. Server relative URL of the page, e.g. /sites/demo/SitePages/Test.aspx |
Returns
System. Returns the HTML contents of a wiki page |
LoadClientSidePage(Web, String)
Loads a client side "modern" page
Declaration
public static IPage LoadClientSidePage(this Web web, string pageName)
Parameters
Web
web
Web to load the page from |
System. Name (e.g. demo.aspx) of the page to be loaded |
Returns
IPage
A Client |
LoadClientSidePageAsync(Web, String)
Loads a client side "modern" page
Declaration
public static async Task<IPage> LoadClientSidePageAsync(this Web web, string pageName)
Parameters
Web
web
Web to load the page from |
System. Name (e.g. demo.aspx) of the page to be loaded |
Returns
Task<IPage>
A Client |
SetWebPartProperty(Web, String, Boolean, Guid, String)
Sets a web part property
Declaration
public static void SetWebPartProperty(this Web web, string key, bool value, Guid id, string serverRelativePageUrl)
Parameters
Web
web
The web to process |
System. The key to update |
System. The value to set |
Guid
id
The id of the webpart |
System. Server relative URL of the page to set web part property |
SetWebPartProperty(Web, String, Int32, Guid, String)
Sets a web part property
Declaration
public static void SetWebPartProperty(this Web web, string key, int value, Guid id, string serverRelativePageUrl)
Parameters
Web
web
The web to process |
System. The key to update |
System. The value to set |
Guid
id
The id of the webpart |
System. Server relative URL of the page to set web part property |
SetWebPartProperty(Web, String, String, Guid, String)
Sets a web part property
Declaration
public static void SetWebPartProperty(this Web web, string key, string value, Guid id, string serverRelativePageUrl)
Parameters
Web
web
The web to process |
System. The key to update |
System. The value to set |
Guid
id
The id of the webpart |
System. Server relative URL of the page to set web part property |