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?
-
i think your referring to this sharepoint.stackexchange.com/questions/86157/… – Ali Jafer Apr 24 '18 at 11:09
-
Final destination for both the questions are different. But I want to know the type directly instead of any other way. – Mihir Apr 24 '18 at 15:34
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.
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.