For a Content Editor Web Part for example it seems we can update Width but not Content:

webPart.Properties["Width"] = "100px";
clientContext.ExecuteQuery(); // Works

webPart.Properties["Content"] = "CEWP Content";
clientContext.ExecuteQuery(); // throws "The Content property does not exist"

Can we only update some common web part properties?

(web service support seems quite bad: http://msdn.microsoft.com/en-us/library/office/websvcwebpartpages.webpartpageswebservice.savewebpart(v=office.15).aspx)

1 Answer 1


I know you have CSOM here, but you don't have an answer yet so I thought I'd try to help where I can. The code below is JSOM. There may be similar functionality on the C# side of the house. Hopefully this provides at least some help. As far as what you can/cannot edit the way you are trying, I would think it is the common elements such as those found in the UI menu when you edit web part properties.

var oPage = web.getFileByServerRelativeUrl(url);
var oLimitedWebPartManager = oPage.getLimitedWebPartManager(SP.WebParts.PersonalizationScope.shared);
var oWebPartXml = '<?xml version=\"1.0\" encoding=\"utf-8\"?>' +
  '<WebPart xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"' +
  ' xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"' +
  ' xmlns=\"http://schemas.microsoft.com/WebPart/v2\">' +
  '<Title>' + title + '</Title><FrameType>Default</FrameType>' +
  '<Description>' + description + '</Description>' +
  '<IsIncluded>true</IsIncluded><ZoneID></ZoneID><PartOrder></PartOrder>' +
  '<FrameState>Normal</FrameState><Height /><Width /><AllowRemove>true</AllowRemove>' +
  '<AllowZoneChange>true</AllowZoneChange><AllowMinimize>true</AllowMinimize>' +
  '<AllowConnect>true</AllowConnect><AllowEdit>true</AllowEdit>' +
  '<AllowHide>true</AllowHide><IsVisible>false</IsVisible><DetailLink /><HelpLink />' +
  '<HelpMode>Modeless</HelpMode><Dir>Default</Dir><PartImageSmall />' +
  '<MissingAssembly>Cannot import this Web Part.</MissingAssembly>' +
  '<PartImageLarge>/_layouts/images/mscontl.gif</PartImageLarge><IsIncludedFilter />' +
  '<Assembly>Microsoft.SharePoint, Version=, Culture=neutral, ' +
  'PublicKeyToken=94de0004b6e3fcc5</Assembly>' +
  '<TypeName>Microsoft.SharePoint.WebPartPages.ContentEditorWebPart</TypeName>' +
  '<ContentLink xmlns=\"http://schemas.microsoft.com/WebPart/v2/ContentEditor\" >' + link + '</ContentLink>' +
  '<Content xmlns=\"http://schemas.microsoft.com/WebPart/v2/ContentEditor\">' +
  '<![CDATA[' + cdata + ']]></Content>' +
  '<PartStorage xmlns=\"http://schemas.microsoft.com/WebPart/v2/ContentEditor\" /></WebPart>';

var oWebPartDefinition = oLimitedWebPartManager.importWebPart(oWebPartXml);
var oWebpart = webPartDefinition.get_webPart();
oLimitedWebPartManager.addWebPart(oWebpart, webpartZone, webpartIndex);

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.