-
StackOverflow 文档
-
sharepoint 教程
-
使用托管客户端对象模型(CSOM)
-
网络部分。从页面中删除 Web 部件
ClientContext oClientContext = new ClientContext("http://MyServer/sites/MySiteCollection");
File oFile = oClientContext.Web.GetFileByServerRelativeUrl("/sites/MySiteCollection/SitePages/Home.aspx ");
LimitedWebPartManager limitedWebPartManager = oFile.GetLimitedWebPartManager(PersonalizationScope.Shared);
oClientContext.Load(limitedWebPartManager.WebParts);
oClientContext.ExecuteQuery();
if (limitedWebPartManager.WebParts.Count == 0)
{
throw new Exception("No Web Parts to delete.");
}
WebPartDefinition webPartDefinition = limitedWebPartManager.WebParts[0];
webPartDefinition.DeleteWebPart();
oClientContext.ExecuteQuery();