gpt4 book ai didi

sharepoint-2010 - 如何以编程方式创建 SharePoint 2010 内容查询 Web 部件?

转载 作者:行者123 更新时间:2023-12-04 07:09:02 25 4
gpt4 key购买 nike

如何以编程方式创建 SharePoint 2010 内容查询 Web 部件并将其添加到 SharePoint 页面?

最佳答案

帖子Adding/Removing web part in SharePoint website programmatically using C# code包含有关添加和删除 Web 部件的详细说明。

这是从上面的帖子中摘录的一个片段,将 Web 部件添加到页面(将 WebPartToBeAdded 伪类替换为 ContentByQueryWebPart):

using (SPSite spSiteTest = new SPSite(“SiteURL”) 
{
using (SPWeb spWebTest = spSiteTest.OpenWeb())
{
SPWebPartCollection webparts = spWebTest.GetWebPartCollection("WebPageURL",Storage.Shared);

//create new webpart object
WebPartToBeAdded wpNew = new WebPartToBeAdded();

//set properties of new webpart object
wpNew.ZoneID = "WebPartZoneIDWhereWebPartIsToBeAdded";
wpNew.Title = "Web Part Title";
wpNew.ChromeState = System.Web.UI.WebControls.WebParts.PartChromeState.Normal;
wpNew.ChromeType = System.Web.UI.WebControls.WebParts.PartChromeType.None;

//add new webpart object to webparts collection
webparts.Add(wpNew);

//update spWeb object
spWebTest.Update();
}
}

关于sharepoint-2010 - 如何以编程方式创建 SharePoint 2010 内容查询 Web 部件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6366257/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com