using System;
using Microsoft.SharePoint.Client;
using Microsoft.SharePoint.Client.WebParts;
namespace SampleCode
{
class DeleteWebPart
{
static void Main()
{
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();
}
}
}
All the question that scared me now i am trying to scare them .. so that they cant scare others :)
Subscribe to:
Post Comments (Atom)
Featured Posts
How to Auto-Terminate Frozen and Hung Apps in Windows
We have all been there. You are in the middle of an important project or a gaming session, and suddenly, your screen freezes. The dreaded ...
-
public struct CoOrds { public int x, y; public CoOrds( int p1, int p2) { x = p1; y = p2; } }
-
Manage timer jobs You can check the status of a timer job and edit the timer job definition. For the general administration of ...
No comments:
Post a Comment
Thank you for Commenting Will reply soon ......