1

I need to Access Web parts Content Property but it is not available in Web Part Properties when I tried with Client side object model C#.

Please find below reference links for detail information.

Which web part properties can / cannot be edited using CSOM?

https://msdn.microsoft.com/en-us/library/office/ee539301(v=office.14).aspx

http://wendellj.blogspot.in/2012/03/c-add-content-editor-web-part.html

I am able to getTitle of web Part but I need the content

2
  • Have you tried requesting the page by creating a HttpWebRequest and then read the HTML from the response? Commented May 5, 2015 at 11:50
  • its a simple web application just try to access all web parts of current page , able to access list and libraries added as a web part in page, but when try to get content editor properties unable to get content property Commented May 5, 2015 at 11:54

2 Answers 2

1

The CSOM LimitedWebPartManager only allows import of a web part, but not export. So no, you cannot access the Content property.

There is an Office UserVoice suggestion to introduce this CSOM capability: https://officespdev.uservoice.com/forums/224641-general/suggestions/6413925-expose-microsoft-sharepoint-webpartpages-splimited

As an alternative for now, you may use the GetWebPart2 method of the WebPartPagesWebService to get the content: https://msdn.microsoft.com/en-us/library/aa979489(v=office.12).aspx

0

If this helps someone else,

using(ClientContext ctx = new ClientContext("siteURL")) {  
  SecureString password = new SecureString();
  ctx.Credentials = new SharePointOnlineCredentials("onlineEmail", password);
  File file = ctx.Web.GetFileByServerRelativeUrl("/pages/default.aspx");
  LimitedWebPartManager wpManager = file.GetLimitedWebPartManager(PersonalizationScope.Shared);
  Guid wpID= new Guid("{GUID}");
  ClientResult<string> wpXml= wpManager.ExportWebPart(wpID);
  ctx.ExecuteQuery();

  //Parse wpXml.Value to get Content Element
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.