-2
如何設置用於以編程方式在SharePoint 2010中發佈頁面的默認頁面佈局?Programmaticaly爲在SharePoint 2010中發佈頁面設置默認頁面佈局
如何設置用於以編程方式在SharePoint 2010中發佈頁面的默認頁面佈局?Programmaticaly爲在SharePoint 2010中發佈頁面設置默認頁面佈局
類似於以下內容,其中layoutName
是文件名,例如MyDefaultLayout.aspx
。
void SetDefaultPageLayout(string layoutName, SPWeb web)
{
var pubWeb = PublishingWeb.GetPublishingWeb(web);
if (pubWeb != null)
{
var pageLayout = pubWeb.GetAvailablePageLayouts()
.Single(pl => pl.Name == layoutName);
pubWeb.SetDefaultPageLayout(pageLayout, true);
pubWeb.Update();
}
}