我不知道你是什麼之後,但我猜你想創建一個頁面並檢查它的名單?
這段代碼確實是在MOSS出版頁:
using (SPWeb web = siteCollection.RootWeb)
{
PublishingSite publishingSite = new PublishingSite(siteCollection);
PublishingWeb publishingWeb = PublishingWeb.GetPublishingWeb(web);
// Article Page content type
SPContentTypeId articleContentTypeID = new SPContentTypeId("0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900242457EFB8B24247815D688C526CD44D");
PageLayout[] layouts = publishingWeb.GetAvailablePageLayouts(articleContentTypeID);
PageLayout articlePageLayout = layouts[0];
string pageName = "LegalInformation.aspx";
SPQuery query = new SPQuery();
query.Query = string.Format("" +
"<Where>" +
"<Eq>" +
"<FieldRef Name='FileLeafRef' />" +
"<Value Type='File'>{0}</Value>" +
"</Eq>" +
"</Where>" +
"", pageName);
// Does the file already exists ?
PublishingPageCollection pageColl = publishingWeb.GetPublishingPages(query);
if (pageColl.Count > 0)
{
return;
}
PublishingPage newPage = publishingWeb.GetPublishingPages().Add(pageName, articlePageLayout);
newPage.ListItem[FieldId.Title] = "This page title";
newPage.ListItem[FieldId.PublishingPageContent] = "<P style='MARGIN-TOP: 20px'>Your content here</P>"";
newPage.Update();
// Check in file
if (newPage.ListItem.File.CheckOutStatus != SPFile.SPCheckOutStatus.None)
{
newPage.ListItem.File.CheckIn(string.Empty);
}
// Publish file
newPage.ListItem.File.Publish(string.Empty);
}
你是不是想以編程方式創建一個頁面?你想把這個頁面放在一個列表中? – 2009-09-23 12:10:00
不,頁面不是以編程方式創建的 - 它駐留在程序集中。不過,我想以編程方式將該頁面添加到共享點虛擬文件系統。 – 2009-09-23 13:01:52