Table of Contents

Interface IPage

Namespace
PnP.Core.Model.SharePoint
Assembly
PnP.Core.dll

A modern SharePoint Page

public interface IPage

Properties

Controls

List of control on this page

List<ICanvasControl> Controls { get; }

Property Value

List<ICanvasControl>

DefaultSection

The default section of the client side page

ICanvasSection DefaultSection { get; }

Property Value

ICanvasSection

EditorType

Returns the editor that was used to create/update this page

EditorType EditorType { get; }

Property Value

EditorType

EntityId

Entity id field for topic pages

string EntityId { get; set; }

Property Value

string

EntityRelations

Entity relations field for topic pages

string EntityRelations { get; set; }

Property Value

string

EntityType

Entity type field for topic pages

string EntityType { get; set; }

Property Value

string

Folder

Folder the page lives in (available after saving the page)

string Folder { get; }

Property Value

string

HeaderControls

List of controls on this page's header

List<ICanvasControl> HeaderControls { get; }

Property Value

List<ICanvasControl>

KeepDefaultWebParts

When a page of type Home is created you can opt to only keep the default client side web parts by setting this to true. This also is a way to reset your home page back the the stock one.

bool KeepDefaultWebParts { get; set; }

Property Value

bool

LayoutType

Layout type of the client side page

PageLayoutType LayoutType { get; set; }

Property Value

PageLayoutType

Name

The name of this page (available after saving the page)

string Name { get; }

Property Value

string

PageHeader

Returns the page header for this page

IPageHeader PageHeader { get; }

Property Value

IPageHeader

PageId

ID value of the page (only available when the page was saved)

int? PageId { get; }

Property Value

int?

PageListItem

ListItem linked to this page

IListItem PageListItem { get; }

Property Value

IListItem

PageTitle

Title of the client side page

string PageTitle { get; set; }

Property Value

string

PagesLibrary

Pages library

IList PagesLibrary { get; }

Property Value

IList

PnPContext

PnPContext to work with

PnPContext PnPContext { get; }

Property Value

PnPContext

RepostDescription

Description of the repost page

string RepostDescription { get; set; }

Property Value

string

RepostSourceItemId

Id of the SharePoint IListItem connected to the page being reposted

Guid RepostSourceItemId { get; set; }

Property Value

Guid

RepostSourceListId

Id of the SharePoint IList containting the page being reposted

Guid RepostSourceListId { get; set; }

Property Value

Guid

RepostSourceSiteId

Id of the SharePoint ISite containting the page being reposted

Guid RepostSourceSiteId { get; set; }

Property Value

Guid

RepostSourceUrl

Url being reposted using the repost page

string RepostSourceUrl { get; set; }

Property Value

string

RepostSourceWebId

Id of the SharePoint IWeb containting the page being reposted

Guid RepostSourceWebId { get; set; }

Property Value

Guid

ScheduledPublishDate

Returns the scheduled publish data of a page (only if publish was scheduled)

DateTime? ScheduledPublishDate { get; }

Property Value

DateTime?

Sections

List of sections on this page

List<ICanvasSection> Sections { get; }

Property Value

List<ICanvasSection>

SpaceContent

Space content field (JSON) for spaces pages

string SpaceContent { get; set; }

Property Value

string

ThumbnailUrl

Thumbnail url for the page

string ThumbnailUrl { get; set; }

Property Value

string

Methods

AddControl(ICanvasControl, ControlFlexLayoutPosition)

Adds a new control to your client side page using the default ICanvasSection

void AddControl(ICanvasControl control, ControlFlexLayoutPosition controlFlexLayoutPosition = null)

Parameters

control ICanvasControl

ICanvasControl to add

controlFlexLayoutPosition ControlFlexLayoutPosition

Optional ControlFlexLayoutPosition to define the position of the control in a flexible layout

AddControl(ICanvasControl, ICanvasColumn, ControlFlexLayoutPosition)

Adds a new control to your client side page in the given section

void AddControl(ICanvasControl control, ICanvasColumn column, ControlFlexLayoutPosition controlFlexLayoutPosition = null)

Parameters

control ICanvasControl

ICanvasControl to add

column ICanvasColumn

ICanvasColumn that will hold the control

controlFlexLayoutPosition ControlFlexLayoutPosition

Optional ControlFlexLayoutPosition to define the position of the control in a flexible layout

AddControl(ICanvasControl, ICanvasColumn, int, ControlFlexLayoutPosition)

Adds a new control to your client side page in the given section with a given order

void AddControl(ICanvasControl control, ICanvasColumn column, int order, ControlFlexLayoutPosition controlFlexLayoutPosition = null)

Parameters

control ICanvasControl

ICanvasControl to add

column ICanvasColumn

ICanvasColumn that will hold the control

order int

Order of the control in the given section

controlFlexLayoutPosition ControlFlexLayoutPosition

Optional ControlFlexLayoutPosition to define the position of the control in a flexible layout

AddControl(ICanvasControl, ICanvasSection, ControlFlexLayoutPosition)

Adds a new control to your client side page in the given section

void AddControl(ICanvasControl control, ICanvasSection section, ControlFlexLayoutPosition controlFlexLayoutPosition = null)

Parameters

control ICanvasControl

ICanvasControl to add

section ICanvasSection

ICanvasSection that will hold the control. Control will end up in the DefaultColumn.

controlFlexLayoutPosition ControlFlexLayoutPosition

Optional ControlFlexLayoutPosition to define the position of the control in a flexible layout

AddControl(ICanvasControl, ICanvasSection, int, ControlFlexLayoutPosition)

Adds a new control to your client side page in the given section with a given order

void AddControl(ICanvasControl control, ICanvasSection section, int order, ControlFlexLayoutPosition controlFlexLayoutPosition = null)

Parameters

control ICanvasControl

ICanvasControl to add

section ICanvasSection

ICanvasSection that will hold the control. Control will end up in the DefaultColumn.

order int

Order of the control in the given section

controlFlexLayoutPosition ControlFlexLayoutPosition

Optional ControlFlexLayoutPosition to define the position of the control in a flexible layout

AddControl(ICanvasControl, int, ControlFlexLayoutPosition)

Adds a new control to your client side page using the default ICanvasSection using a given order

void AddControl(ICanvasControl control, int order, ControlFlexLayoutPosition controlFlexLayoutPosition = null)

Parameters

control ICanvasControl

ICanvasControl to add

order int

Order of the control in the default section

controlFlexLayoutPosition ControlFlexLayoutPosition

Optional ControlFlexLayoutPosition to define the position of the control in a flexible layout

AddHeaderControl(ICanvasControl, int)

Adds a new header control to your client side page with a given order. Used for topic page creation

void AddHeaderControl(ICanvasControl control, int order)

Parameters

control ICanvasControl

ICanvasControl to add

order int

Order of the control in the given section

AddSection(CanvasSectionTemplate, float, VariantThemeType, VariantThemeType, ZoneReflowStrategy?)

Adds a new section to your client side page

void AddSection(CanvasSectionTemplate sectionTemplate, float order, VariantThemeType zoneEmphasis, VariantThemeType verticalSectionZoneEmphasis = VariantThemeType.None, ZoneReflowStrategy? zoneReflowStrategy = null)

Parameters

sectionTemplate CanvasSectionTemplate

The CanvasSectionTemplate type of the section

order float

Controls the order of the new section

zoneEmphasis VariantThemeType

Zone emphasis (section background)

verticalSectionZoneEmphasis VariantThemeType

Vertical Section Zone emphasis (section background)

zoneReflowStrategy ZoneReflowStrategy?

Optional ZoneReflowStrategy to define how the section should reflow in a responsive layout

AddSection(CanvasSectionTemplate, float, int, int?, ZoneReflowStrategy?)

Adds a new section to your client side page

void AddSection(CanvasSectionTemplate sectionTemplate, float order, int zoneEmphasis, int? verticalSectionZoneEmphasis = null, ZoneReflowStrategy? zoneReflowStrategy = null)

Parameters

sectionTemplate CanvasSectionTemplate

The CanvasSectionTemplate type of the section

order float

Controls the order of the new section

zoneEmphasis int

Zone emphasis (section background)

verticalSectionZoneEmphasis int?

Vertical Section Zone emphasis (section background)

zoneReflowStrategy ZoneReflowStrategy?

Optional ZoneReflowStrategy to define how the section should reflow in a responsive layout

AddSection(CanvasSectionTemplate, float, ZoneReflowStrategy?)

Adds a new section to your client side page

void AddSection(CanvasSectionTemplate sectionTemplate, float order, ZoneReflowStrategy? zoneReflowStrategy = null)

Parameters

sectionTemplate CanvasSectionTemplate

The CanvasSectionTemplate type of the section

order float

Controls the order of the new section

zoneReflowStrategy ZoneReflowStrategy?

Optional ZoneReflowStrategy to define how the section should reflow in a responsive layout

AddSection(ICanvasSection)

Adds a new section to your client side page

void AddSection(ICanvasSection section)

Parameters

section ICanvasSection

ICanvasSection object describing the section to add

AddSection(ICanvasSection, float)

Adds a new section to your client side page with a given order

void AddSection(ICanvasSection section, float order)

Parameters

section ICanvasSection

ICanvasSection object describing the section to add

order float

Controls the order of the new section

AreCommentsDisabled()

Does this page have comments disabled

bool AreCommentsDisabled()

Returns

bool

AreCommentsDisabledAsync()

Does this page have comments disabled

Task<bool> AreCommentsDisabledAsync()

Returns

Task<bool>

AvailablePageComponents(string)

Gets a list of available client side web parts to use, optionally filtered by a given name

IEnumerable<IPageComponent> AvailablePageComponents(string name = null)

Parameters

name string

Name of the web part to retrieve

Returns

IEnumerable<IPageComponent>

List of available IPageComponent

AvailablePageComponentsAsync(string)

Gets a list of available client side web parts to use, optionally filtered by a given name

Task<IEnumerable<IPageComponent>> AvailablePageComponentsAsync(string name = null)

Parameters

name string

Name of the web part to retrieve

Returns

Task<IEnumerable<IPageComponent>>

List of available IPageComponent

ClearPage()

Clears the sections and controls from the page

void ClearPage()

DefaultWebPartToWebPartId(DefaultWebPart)

Translates a given DefaultWebPart enum to it's corresponding web part id. Non default web parts will be returned as empty string

string DefaultWebPartToWebPartId(DefaultWebPart webPart)

Parameters

webPart DefaultWebPart

DefaultWebPart enum to translate to it's id

Returns

string

The corresponding web part id

Delete()

Deletes the created page

void Delete()

DeleteAsync()

Deletes the created page

Task DeleteAsync()

Returns

Task

DemoteNewsArticle()

Demotes an client side Article news page as a regular client side page

void DemoteNewsArticle()

DemoteNewsArticleAsync()

Demotes an client side Article news page as a regular client side page

Task DemoteNewsArticleAsync()

Returns

Task

DisableComments()

Disable commenting on this page

void DisableComments()

DisableCommentsAsync()

Disable commenting on this page

Task DisableCommentsAsync()

Returns

Task

EnableComments()

Enable commenting on this page

void EnableComments()

EnableCommentsAsync()

Enable commenting on this page

Task EnableCommentsAsync()

Returns

Task

GetComments(params Expression<Func<IComment, object>>[])

Get list item comments

ICommentCollection GetComments(params Expression<Func<IComment, object>>[] selectors)

Parameters

selectors Expression<Func<IComment, object>>[]

The expressions declaring the fields to select

Returns

ICommentCollection

GetCommentsAsync(params Expression<Func<IComment, object>>[])

Get list item comments

Task<ICommentCollection> GetCommentsAsync(params Expression<Func<IComment, object>>[] selectors)

Parameters

selectors Expression<Func<IComment, object>>[]

The expressions declaring the fields to select

Returns

Task<ICommentCollection>

GetImageWebPart(string, PageImageOptions)

Prepares an Image web part for adding to a page

IPageWebPart GetImageWebPart(string serverRelativeUrl, PageImageOptions imageOptions = null)

Parameters

serverRelativeUrl string

Server relative url of the image to show in the image web part

imageOptions PageImageOptions

Options to configure the image when being added

Returns

IPageWebPart

Configured image web part which can be added to the page

GetImageWebPartAsync(string, PageImageOptions)

Prepares an Image web part for adding to a page

Task<IPageWebPart> GetImageWebPartAsync(string serverRelativeUrl, PageImageOptions imageOptions = null)

Parameters

serverRelativeUrl string

Server relative url of the image to show in the image web part

imageOptions PageImageOptions

Options to configure the image when being added

Returns

Task<IPageWebPart>

Configured image web part which can be added to the page

GetInlineImage(IPageText, string, PageImageOptions)

Prepares an inline image for adding to text by adding the needed image web part and returning the HTML snippet that needs to be appended to the text editor content

string GetInlineImage(IPageText textEditorInstance, string serverRelativeUrl, PageImageOptions imageOptions = null)

Parameters

textEditorInstance IPageText

Text editor instance to add the inline image to

serverRelativeUrl string

Server relative url of the image to add inline

imageOptions PageImageOptions

Options to configure the inline image when being added

Returns

string

Html snippet to be appended to the text editor content

GetInlineImageAsync(IPageText, string, PageImageOptions)

Prepares an inline image for adding to text by adding the needed image web part and returning the HTML snippet that needs to be appended to the text editor content

Task<string> GetInlineImageAsync(IPageText textEditorInstance, string serverRelativeUrl, PageImageOptions imageOptions = null)

Parameters

textEditorInstance IPageText

Text editor instance to add the inline image to, when the PnP.Core.Model.SharePoint.Page.EditorType is CK5 then this can be left null

serverRelativeUrl string

Server relative url of the image to add inline

imageOptions PageImageOptions

Options to configure the inline image when being added

Returns

Task<string>

Html snippet to be appended to the text editor content

GetLikedByInformation()

Returns information about the likes on this page

ILikedByInformation GetLikedByInformation()

Returns

ILikedByInformation

GetLikedByInformationAsync()

Returns information about the likes on this page

Task<ILikedByInformation> GetLikedByInformationAsync()

Returns

Task<ILikedByInformation>

GetPageFile(params Expression<Func<IFile, object>>[])

Gets the file connected to this page

IFile GetPageFile(params Expression<Func<IFile, object>>[] expressions)

Parameters

expressions Expression<Func<IFile, object>>[]

Properties to load for the file

Returns

IFile

The connected IFile

GetPageFileAsync(params Expression<Func<IFile, object>>[])

Gets the file connected to this page

Task<IFile> GetPageFileAsync(params Expression<Func<IFile, object>>[] expressions)

Parameters

expressions Expression<Func<IFile, object>>[]

Properties to load for the file

Returns

Task<IFile>

The connected IFile

GetPageTranslations()

Returns the page translation status for a given page

IPageTranslationStatusCollection GetPageTranslations()

Returns

IPageTranslationStatusCollection

IPageTranslationStatusCollection list containing information about this page's translations

GetPageTranslationsAsync()

Returns the page translation status for a given page

Task<IPageTranslationStatusCollection> GetPageTranslationsAsync()

Returns

Task<IPageTranslationStatusCollection>

IPageTranslationStatusCollection list containing information about this page's translations

GetTemplatesFolder()

Returns the name of the templates folder, and creates if it doesn't exist.

string GetTemplatesFolder()

Returns

string

GetTemplatesFolderAsync()

Returns the name of the templates folder, and creates if it doesn't exist.

Task<string> GetTemplatesFolderAsync()

Returns

Task<string>

InstantiateDefaultWebPart(DefaultWebPart)

Instantiates a new web part with default data and returns it

IPageWebPart InstantiateDefaultWebPart(DefaultWebPart webPart)

Parameters

webPart DefaultWebPart

Default web part to instantiate

Returns

IPageWebPart

Instantiated web part

InstantiateDefaultWebPartAsync(DefaultWebPart)

Instantiates a new web part with default data and returns it

Task<IPageWebPart> InstantiateDefaultWebPartAsync(DefaultWebPart webPart)

Parameters

webPart DefaultWebPart

Default web part to instantiate

Returns

Task<IPageWebPart>

Instantiated web part

Like()

Likes a page

void Like()

LikeAsync()

Likes a page

Task LikeAsync()

Returns

Task

NewSectionBackgroundControl()

Creates a new section background image web part

IPageWebPart NewSectionBackgroundControl()

Returns

IPageWebPart

The created web part

NewTextPart(string)

Creates a new text part which can be configured and added to the page

IPageText NewTextPart(string text = null)

Parameters

text string

Optionally provide the text for the text part

Returns

IPageText

The created text part

NewWebPart(IPageComponent)

Creates a new web part

IPageWebPart NewWebPart(IPageComponent clientSideComponent = null)

Parameters

clientSideComponent IPageComponent

The base component to use for this web part

Returns

IPageWebPart

The created web part

PromoteAsHomePage()

Sets the current IPage as home page for the current site

void PromoteAsHomePage()

PromoteAsHomePageAsync()

Sets the current IPage as home page for the current site

Task PromoteAsHomePageAsync()

Returns

Task

PromoteAsNewsArticle()

Promotes a regular Article client side page as a news page

void PromoteAsNewsArticle()

PromoteAsNewsArticleAsync()

Promotes a regular Article client side page as a news page

Task PromoteAsNewsArticleAsync()

Returns

Task

Publish(string)

Publishes a client side page

void Publish(string comment = null)

Parameters

comment string

Publishing comment

PublishAsync(string)

Publishes a client side page

Task PublishAsync(string comment = null)

Parameters

comment string

Publishing comment

Returns

Task

RemovePageHeader()

Removes the set page header by setting the page banner web part to "Plain" mode

void RemovePageHeader()

RemoveSchedulePublish()

Removes the publication schedule of a client side page

void RemoveSchedulePublish()

RemoveSchedulePublishAsync()

Removes the publication schedule of a client side page

Task RemoveSchedulePublishAsync()

Returns

Task

Save(string)

Saves the page to the pages library

string Save(string pageName = null)

Parameters

pageName string

Page name to use

Returns

string

The name of the saved page

SaveAsTemplate(string)

Saves the page as a template page

string SaveAsTemplate(string pageName = null)

Parameters

pageName string

Page name to use

Returns

string

The name of the saved page

SaveAsTemplateAsync(string)

Saves the page as a template page

Task<string> SaveAsTemplateAsync(string pageName = null)

Parameters

pageName string

Page name to use

Returns

Task<string>

The name of the saved page

SaveAsync(string)

Saves the page to the pages library

Task<string> SaveAsync(string pageName = null)

Parameters

pageName string

Page name to use

Returns

Task<string>

The name of the saved page

SchedulePublish(DateTime)

Schedules the publication of a client side page

void SchedulePublish(DateTime publishDate)

Parameters

publishDate DateTime

Date when the page needs to be publishing

SchedulePublishAsync(DateTime)

Schedules the publication of a client side page

Task SchedulePublishAsync(DateTime publishDate)

Parameters

publishDate DateTime

Date when the page needs to be publishing

Returns

Task

SetCustomPageHeader(string, double?, double?)

Sets page header with custom focal point

void SetCustomPageHeader(string serverRelativeImageUrl, double? translateX = null, double? translateY = null)

Parameters

serverRelativeImageUrl string

Server relative page header image url

translateX double?

X focal point for image

translateY double?

Y focal point for image

SetDefaultPageHeader()

Sets page header back to the default page header

void SetDefaultPageHeader()

SetPageTitleWebPartPageHeader()

Sets page header back to the default for PageTilte WebPart (Message ID: MC791596 / Roadmap ID: 386904). The PageTitle WebPart has to be added into a first OneColumnFullWith Section separate.

void SetPageTitleWebPartPageHeader()

TranslatePages()

Creates page translations for all the languages defined as multi-lingual languages in the site

IPageTranslationStatusCollection TranslatePages()

Returns

IPageTranslationStatusCollection

IPageTranslationStatusCollection list containing information about this page's translations

TranslatePages(PageTranslationOptions)

Creates page translations for the requested languages

IPageTranslationStatusCollection TranslatePages(PageTranslationOptions pageTranslationOptions)

Parameters

pageTranslationOptions PageTranslationOptions

Options describing the languages in which a translation needs to be created

Returns

IPageTranslationStatusCollection

IPageTranslationStatusCollection list containing information about this page's translations

TranslatePagesAsync()

Creates page translations for all the languages defined as multi-lingual languages in the site

Task<IPageTranslationStatusCollection> TranslatePagesAsync()

Returns

Task<IPageTranslationStatusCollection>

IPageTranslationStatusCollection list containing information about this page's translations

TranslatePagesAsync(PageTranslationOptions)

Creates page translations for the requested languages

Task<IPageTranslationStatusCollection> TranslatePagesAsync(PageTranslationOptions pageTranslationOptions)

Parameters

pageTranslationOptions PageTranslationOptions

Options describing the languages in which a translation needs to be created

Returns

Task<IPageTranslationStatusCollection>

IPageTranslationStatusCollection list containing information about this page's translations

Unlike()

Unlikes a page

void Unlike()

UnlikeAsync()

Unlikes a page

Task UnlikeAsync()

Returns

Task

WebPartIdToDefaultWebPart(string)

Translated a given web part id to a DefaultWebPart enum. Non default web parts will be returned as ThirdParty

DefaultWebPart WebPartIdToDefaultWebPart(string id)

Parameters

id string

Web part id to lookup

Returns

DefaultWebPart

Corresponding DefaultWebPart enum value