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

  • Have you tried requesting the page by creating a HttpWebRequest and then read the HTML from the response? – Amal Hashim May 5 '15 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 – Sharepoint Beginner May 5 '15 at 11:54
0

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

-1

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, privacy policy and cookie policy

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