using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Client;
using Microsoft.SharePoint.Client.WebParts;
namespace ClientObjectModel
{
class Program
{
static void Main(string[] args)
{
//Get all the web parts from the page using client object model
ClientContext context = new ClientContext("http://serverName:1111");
File file = context.Web.GetFileByServerRelativeUrl("/Shared%20Documents/Forms/AllItems.aspx");
LimitedWebPartManager wpm = file.GetLimitedWebPartManager(PersonalizationScope.Shared);
context.Load(wpm.WebParts,
wps => wps.Include(
wp => wp.WebPart.Title));
context.ExecuteQuery();
foreach (WebPartDefinition wpd in wpm.WebParts)
{
WebPart wp = wpd.WebPart;
Console.WriteLine(wp.Title);
}
Console.ReadLine();
}
}
}
Join the conversation! Your thoughts help the community grow.
Sign in to leave a comment
It is the same account you read, post and publish with — and you will come straight back to this page.

Muthu VPosted Aug 1, 2016, 3:57 AM
Wp.GetType().FullName does not return us the exact WebPart type. This always returns us Microsoft.SharePoint.Client.WebParts.WebPart. Is there any way to find exactly the WebPart type
nata rajanPosted Jan 9, 2013, 10:51 AM
Nice code snippet. Thank you Vijai. Can you please post the sample code to to get the rendered data from webpart(site page). I am very new to this.