【发布时间】:2012-01-15 17:46:24
【问题描述】:
我想创建几个包含自定义 Web 部件的 Web 部件页面(以编程方式)。 我已经搜索了 internetz,但找不到任何我可以开始工作的东西。
到目前为止,这是我的代码(我在其中创建欢迎页面,而不是 Web 部件页面):
using (SPSite site = new SPSite("http://v99-sp-public/"))
{
using (SPWeb web = site.OpenWeb())
{
PublishingSite pSite = new PublishingSite(site);
SPContentType ctype = pSite.ContentTypes["Welcome Page"];
PageLayoutCollection pageLayouts = pSite.GetPageLayouts(ctype, true);
PageLayout pageLayout = pageLayouts["/_catalogs/masterpage/welcomesplash.aspx"];
PublishingWeb pWeb = PublishingWeb.GetPublishingWeb(web);
PublishingPageCollection pPages = pWeb.GetPublishingPages();
PublishingPage pPage = pPages.Add("Klanten2.aspx", pageLayout);
SPListItem newpage = pPage.ListItem;
newpage["Title"] = "Klanten";
newpage.Update();
newpage.File.CheckIn("Checkin");
newpage.File.Publish("Publisch");
}
}
请帮帮我,
谢谢。
【问题讨论】:
标签: c# sharepoint web-parts