Skip to content

Instantly share code, notes, and snippets.

@chrisobriensp
Created March 13, 2017 14:43
Show Gist options
  • Select an option

  • Save chrisobriensp/1ccf1d7c74b830397b3742d5211ca09b to your computer and use it in GitHub Desktop.

Select an option

Save chrisobriensp/1ccf1d7c74b830397b3742d5211ca09b to your computer and use it in GitHub Desktop.
Shows PnP core methods to create/modify modern SharePoint pages.
private static void createPage(ClientContext siteContext, string pageName)
{
ClientSidePage page = new ClientSidePage(siteContext);
ClientSideText txt1 = new ClientSideText() { Text = "COB test" };
page.AddControl(txt1, 0);
// page will be created if it doesn't exist, otherwise overwritten if it does..
page.Save(pageName);
}
private static void modifyExistingPage(ClientContext siteContext, string pageName)
{
// load exising page - will return null if no page found with this name..
ClientSidePage page = ClientSidePage.Load(siteContext, pageName);
ClientSideText txt1 = new ClientSideText() { Text = "COB test" };
page.AddControl(txt1, 0);
page.Save(pageName);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment