Sunday, March 11, 2012

how to create a custom page in sharepoint 2010

Here i will show how to create a custom aspx in share point.In this we get the root Share Point site, Then create a custom page with content and added to page collection .The page collection contains published pages in sharepoint website.Finally we will update the created custom page into collection using update command.
PublishingWeb PubWeb = PublishingWeb.GetPublishingWeb(SPContext.Current.Site.RootWeb);
string PageName = “Home.aspx”;
PageLayout[] layouts = PubWeb.GetAvailablePageLayouts();
PageLayout layout = layouts[0];
PublishingPageCollection  PCpages =PubWeb.GetPublishingPages();
PublishingPage PubPage = PCpages.Add(PageName, layout);
PubPage.ListItem[FieldId.PublishingPageContent] = “Homecontent”;

No comments: