Create page in SharePoint Programatically
SPSecurity.RunWithElevatedPrivileges(delegate()
{
PublishingWeb
pubWeb = PublishingWeb.GetPublishingWeb(web);
string pageName = "CustomSPPage.aspx";
PageLayout[] pageLayouts = publishingWeb.GetAvailablePageLayouts();
PageLayout currPageLayout =
pageLayouts[0];
PublishingPageCollection
pages = publishingWeb.GetPublishingPages();
PublishingPage newPge = pages.Add(pageName, currPageLayout);
newPge.ListItem[FieldId.PublishingPageContent]
= "my Test";
newPge.ListItem.Update();
newPge.Update();
newPge.CheckIn("all is well");
});
No comments:
Post a Comment