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
DefaultSection
The default section of the client side page
ICanvasSection DefaultSection { get; }
Property Value
EditorType
Returns the editor that was used to create/update this page
EditorType EditorType { get; }
Property Value
EntityId
Entity id field for topic pages
string EntityId { get; set; }
Property Value
EntityRelations
Entity relations field for topic pages
string EntityRelations { get; set; }
Property Value
EntityType
Entity type field for topic pages
string EntityType { get; set; }
Property Value
Folder
Folder the page lives in (available after saving the page)
string Folder { get; }
Property Value
HeaderControls
List of controls on this page's header
List<ICanvasControl> HeaderControls { get; }
Property Value
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
LayoutType
Layout type of the client side page
PageLayoutType LayoutType { get; set; }
Property Value
Name
The name of this page (available after saving the page)
string Name { get; }
Property Value
PageHeader
Returns the page header for this page
IPageHeader PageHeader { get; }
Property Value
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
PageTitle
Title of the client side page
string PageTitle { get; set; }
Property Value
PagesLibrary
Pages library
IList PagesLibrary { get; }
Property Value
PnPContext
PnPContext to work with
PnPContext PnPContext { get; }
Property Value
RepostDescription
Description of the repost page
string RepostDescription { get; set; }
Property Value
RepostSourceItemId
Id of the SharePoint IListItem connected to the page being reposted
Guid RepostSourceItemId { get; set; }
Property Value
RepostSourceListId
Id of the SharePoint IList containting the page being reposted
Guid RepostSourceListId { get; set; }
Property Value
RepostSourceSiteId
Id of the SharePoint ISite containting the page being reposted
Guid RepostSourceSiteId { get; set; }
Property Value
RepostSourceUrl
Url being reposted using the repost page
string RepostSourceUrl { get; set; }
Property Value
RepostSourceWebId
Id of the SharePoint IWeb containting the page being reposted
Guid RepostSourceWebId { get; set; }
Property Value
ScheduledPublishDate
Returns the scheduled publish data of a page (only if publish was scheduled)
DateTime? ScheduledPublishDate { get; }
Property Value
Sections
List of sections on this page
List<ICanvasSection> Sections { get; }
Property Value
SpaceContent
Space content field (JSON) for spaces pages
string SpaceContent { get; set; }
Property Value
ThumbnailUrl
Thumbnail url for the page
string ThumbnailUrl { get; set; }
Property Value
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
controlICanvasControlICanvasControl to add
controlFlexLayoutPositionControlFlexLayoutPositionOptional 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
controlICanvasControlICanvasControl to add
columnICanvasColumnICanvasColumn that will hold the control
controlFlexLayoutPositionControlFlexLayoutPositionOptional 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
controlICanvasControlICanvasControl to add
columnICanvasColumnICanvasColumn that will hold the control
orderintOrder of the control in the given section
controlFlexLayoutPositionControlFlexLayoutPositionOptional 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
controlICanvasControlICanvasControl to add
sectionICanvasSectionICanvasSection that will hold the control. Control will end up in the DefaultColumn.
controlFlexLayoutPositionControlFlexLayoutPositionOptional 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
controlICanvasControlICanvasControl to add
sectionICanvasSectionICanvasSection that will hold the control. Control will end up in the DefaultColumn.
orderintOrder of the control in the given section
controlFlexLayoutPositionControlFlexLayoutPositionOptional 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
controlICanvasControlICanvasControl to add
orderintOrder of the control in the default section
controlFlexLayoutPositionControlFlexLayoutPositionOptional 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
controlICanvasControlICanvasControl to add
orderintOrder 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
sectionTemplateCanvasSectionTemplateThe CanvasSectionTemplate type of the section
orderfloatControls the order of the new section
zoneEmphasisVariantThemeTypeZone emphasis (section background)
verticalSectionZoneEmphasisVariantThemeTypeVertical Section Zone emphasis (section background)
zoneReflowStrategyZoneReflowStrategy?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
sectionTemplateCanvasSectionTemplateThe CanvasSectionTemplate type of the section
orderfloatControls the order of the new section
zoneEmphasisintZone emphasis (section background)
verticalSectionZoneEmphasisint?Vertical Section Zone emphasis (section background)
zoneReflowStrategyZoneReflowStrategy?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
sectionTemplateCanvasSectionTemplateThe CanvasSectionTemplate type of the section
orderfloatControls the order of the new section
zoneReflowStrategyZoneReflowStrategy?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
sectionICanvasSectionICanvasSection 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
sectionICanvasSectionICanvasSection object describing the section to add
orderfloatControls the order of the new section
AreCommentsDisabled()
Does this page have comments disabled
bool AreCommentsDisabled()
Returns
AreCommentsDisabledAsync()
Does this page have comments disabled
Task<bool> AreCommentsDisabledAsync()
Returns
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
namestringName 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
namestringName 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
webPartDefaultWebPartDefaultWebPart 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
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
DisableComments()
Disable commenting on this page
void DisableComments()
DisableCommentsAsync()
Disable commenting on this page
Task DisableCommentsAsync()
Returns
EnableComments()
Enable commenting on this page
void EnableComments()
EnableCommentsAsync()
Enable commenting on this page
Task EnableCommentsAsync()
Returns
GetComments(params Expression<Func<IComment, object>>[])
Get list item comments
ICommentCollection GetComments(params Expression<Func<IComment, object>>[] selectors)
Parameters
selectorsExpression<Func<IComment, object>>[]The expressions declaring the fields to select
Returns
GetCommentsAsync(params Expression<Func<IComment, object>>[])
Get list item comments
Task<ICommentCollection> GetCommentsAsync(params Expression<Func<IComment, object>>[] selectors)
Parameters
selectorsExpression<Func<IComment, object>>[]The expressions declaring the fields to select
Returns
GetImageWebPart(string, PageImageOptions)
Prepares an Image web part for adding to a page
IPageWebPart GetImageWebPart(string serverRelativeUrl, PageImageOptions imageOptions = null)
Parameters
serverRelativeUrlstringServer relative url of the image to show in the image web part
imageOptionsPageImageOptionsOptions 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
serverRelativeUrlstringServer relative url of the image to show in the image web part
imageOptionsPageImageOptionsOptions 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
textEditorInstanceIPageTextText editor instance to add the inline image to
serverRelativeUrlstringServer relative url of the image to add inline
imageOptionsPageImageOptionsOptions 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
textEditorInstanceIPageTextText editor instance to add the inline image to, when the PnP.Core.Model.SharePoint.Page.EditorType is CK5 then this can be left null
serverRelativeUrlstringServer relative url of the image to add inline
imageOptionsPageImageOptionsOptions to configure the inline image when being added
Returns
GetLikedByInformation()
Returns information about the likes on this page
ILikedByInformation GetLikedByInformation()
Returns
GetLikedByInformationAsync()
Returns information about the likes on this page
Task<ILikedByInformation> GetLikedByInformationAsync()
Returns
GetPageFile(params Expression<Func<IFile, object>>[])
Gets the file connected to this page
IFile GetPageFile(params Expression<Func<IFile, object>>[] expressions)
Parameters
expressionsExpression<Func<IFile, object>>[]Properties to load for the file
Returns
GetPageFileAsync(params Expression<Func<IFile, object>>[])
Gets the file connected to this page
Task<IFile> GetPageFileAsync(params Expression<Func<IFile, object>>[] expressions)
Parameters
expressionsExpression<Func<IFile, object>>[]Properties to load for the file
Returns
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
GetTemplatesFolderAsync()
Returns the name of the templates folder, and creates if it doesn't exist.
Task<string> GetTemplatesFolderAsync()
Returns
InstantiateDefaultWebPart(DefaultWebPart)
Instantiates a new web part with default data and returns it
IPageWebPart InstantiateDefaultWebPart(DefaultWebPart webPart)
Parameters
webPartDefaultWebPartDefault 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
webPartDefaultWebPartDefault web part to instantiate
Returns
- Task<IPageWebPart>
Instantiated web part
Like()
Likes a page
void Like()
LikeAsync()
Likes a page
Task LikeAsync()
Returns
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
textstringOptionally 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
clientSideComponentIPageComponentThe 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
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
Publish(string)
Publishes a client side page
void Publish(string comment = null)
Parameters
commentstringPublishing comment
PublishAsync(string)
Publishes a client side page
Task PublishAsync(string comment = null)
Parameters
commentstringPublishing comment
Returns
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
Save(string)
Saves the page to the pages library
string Save(string pageName = null)
Parameters
pageNamestringPage 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
pageNamestringPage 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
pageNamestringPage name to use
Returns
SaveAsync(string)
Saves the page to the pages library
Task<string> SaveAsync(string pageName = null)
Parameters
pageNamestringPage name to use
Returns
SchedulePublish(DateTime)
Schedules the publication of a client side page
void SchedulePublish(DateTime publishDate)
Parameters
publishDateDateTimeDate when the page needs to be publishing
SchedulePublishAsync(DateTime)
Schedules the publication of a client side page
Task SchedulePublishAsync(DateTime publishDate)
Parameters
publishDateDateTimeDate when the page needs to be publishing
Returns
SetCustomPageHeader(string, double?, double?)
Sets page header with custom focal point
void SetCustomPageHeader(string serverRelativeImageUrl, double? translateX = null, double? translateY = null)
Parameters
serverRelativeImageUrlstringServer relative page header image url
translateXdouble?X focal point for image
translateYdouble?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
pageTranslationOptionsPageTranslationOptionsOptions 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
pageTranslationOptionsPageTranslationOptionsOptions 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
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
idstringWeb part id to lookup
Returns
- DefaultWebPart
Corresponding DefaultWebPart enum value