0

I am able to get all the webparts on a page using CSOM with C# code. But I am unable to find the way to retrieve only Script editor and content editor webparts on a page. I am not able to see any property which will tells about type of web part. If I use webpart.GetType() then it is giving me as Microsoft.SharePoint.Client.WebParts.WebPartDefinition. No way to identify in client side?

1

There is no way to get the answer for type of web part in CSOM. But one we can check for OOB webpart is with the description. For Script editor: Allows authors to insert HTML snippets or scripts. For Content Editor : Allows authors to enter rich text content. Descriptions will come Resource file. And Every one will not having the access to change description. This way I am able to get the web parts, working fine.

0

In client side, we cannot get the specific web part types of the all web parts. Some web parts just return the basic web part type.

So we cannot get the web part type of the content editor web part and script editor web part using webpart.GetType().

It is by design.

As a workaround, you could consider using title of the web part to get the content editor web part and script web part if you use the default name of the web part.

  • But there is a chance of changing title of the web part by user. – Mihir Jan 8 '18 at 12:07

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.