"add new page to site c# programmatically" Code Answer's
You're definitely familiar with the best coding language C# that developers use to develop their projects and they get all their queries like "add new page to site c# programmatically" answered properly. Developers are finding an appropriate answer about add new page to site c# programmatically related to the C# coding language. By visiting this online portal developers get answers concerning C# codes question like add new page to site c# programmatically. Enter your desired code related query in the search bar and get every piece of information about C# code related question on add new page to site c# programmatically.
add new page to site c# programmatically
private void CreatePage(SPSite site1, string cWebUrl, string cPageLayout, string cPageName, string cPageTitle)
{
try
{
using (SPWeb spoWeb = site1.OpenWeb(cWebUrl))
{
PublishingWeb pWebRoot = PublishingWeb.GetPublishingWeb(site1.RootWeb);
PublishingWeb pWeb = PublishingWeb.GetPublishingWeb(spoWeb);
PageLayout[] layouts = pWebRoot.GetAvailablePageLayouts();
PageLayout pl = GetPageLayout(layouts, cPageLayout);
if (pl != null)
{
//Create My Pages
PublishingPage newPage = pWeb.GetPublishingPages().Add(cPageName, pl);
newPage.Layout = pl;
newPage.Title = cPageTitle;
newPage.Update();
newPage.CheckIn("");
pWeb.Update();
}
}
}
catch (Exception ex)
{
//Error Handling code
}
}
Source: sharepoint.stackexchange.com
All those coders who are working on the C# based application and are stuck on add new page to site c# programmatically can get a collection of related answers to their query. Programmers need to enter their query on add new page to site c# programmatically related to C# code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about add new page to site c# programmatically for the programmers working on C# code while coding their module. Coders are also allowed to rectify already present answers of add new page to site c# programmatically while working on the C# language code. Developers can add up suggestions if they deem fit any other answer relating to "add new page to site c# programmatically". Visit this developer's friendly online web community, CodeProZone, and get your queries like add new page to site c# programmatically resolved professionally and stay updated to the latest C# updates.