gpt4 book ai didi

sharepoint - 在停用该功能时从共享点页面中删除特定的 Web 部件

转载 作者:行者123 更新时间:2023-12-04 06:35:46 28 4
gpt4 key购买 nike

以下是我在 FeatureDeactivation 事件处理程序中添加的代码片段。我无法获得删除 System.Web.UI.WebControls.WebParts 类型的 webpart 的解决方案。

try
{
SPSite mysite = properties.Feature.Parent as SPSite;
SPWeb myweb = mysite.RootWeb;
SPLimitedWebPartManager manager = myweb.GetLimitedWebPartManager("default.aspx", System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared);

using (mysite)
{
using (myweb)
{
SPLimitedWebPartCollection webparts = manager.WebParts;

for (int k = 0; k < webparts.Count; k++)
{
//get reference to webpart
System.Web.UI.WebControls.WebParts.WebPart wp = webparts[k];

//check webpart Title to find webpart which is to be removed
if (wp.Title == "Profile Edit")
{
WHAT CODE SNIPPET HAS TO BE INSERTED HERE TO DELETE THE WEBPART FROM THE PAGE

}
}
}
}

}
catch (Exception ex)
{
eventlog.WriteEntry(String.Format("Error de-activating add tab feature {0} : ", ex.Message));
}

最佳答案

使用以下代码

manager.DeleteWebPart(wp);

manager.Dispose();
web.Update();

关于sharepoint - 在停用该功能时从共享点页面中删除特定的 Web 部件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4897409/

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