1
我想以編程方式創建於2010年的Sharepoint我已經發現此代碼段一的WebPart頁面(.aspx文件):C#創建SharePoint 2010中的WebPart頁面
public static PublishingPage CreatePage(string fileName, string title)
{
PublishingWeb pWeb = PublishingWeb.GetPublishingWeb(Web);
PageLayout[] layouts = pWeb.GetAvailablePageLayouts();
PageLayout layout = layouts[0];
foreach (PageLayout p in layouts)
{
if (p.Name.Equals("BlankWebPartPage.aspx"))
{
layout = p;
break;
}
}
try
{
PublishingPage newPage = pWeb.GetPublishingPages().Add(fileName, layout);
newPage.Title = title;
newPage.Update();
return newPage;
}
catch (Exception)
{
return null;
}
}
但我的問題是SharePoint基礎服務器不有發佈部分,但我必須在SharePoint Foundation Server上運行它。 是否有可能在沒有PublishingWeb的情況下創建Webpart頁面?
迎接
試試這個: http://stackoverflow.com/questions/979635/programmatically-instantiate-a-web-part-page-in-sharepoint – Chinmaya003