I know it can be done with client side coding, but maybe there is a built in way to do this in SharePoint 2013. I have a web part I share with other sites, but do not want site administrators seeing or editing the web part contents through the normal sharepoint page edit UI > Edit Web Part > Edit Snippet.

Might it there be a switch in the webpart xml to disable that?
Possible to create a new or change the web part type that does not have the Edit Snippet feature?

this is the Web Part XML source of a very simple web part anybody with site admin rights on the site can edit via the UI.

enter image description here

enter image description here

  <webPart xmlns="http://schemas.microsoft.com/WebPart/v3" Gr="Test">
      <type name="Microsoft.SharePoint.WebPartPages.ScriptEditorWebPart, Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
      <importErrorMessage>Cannot import this Web Part.</importErrorMessage>
        <property name="ExportMode" type="exportmode">None</property>
        <property name="HelpUrl" type="string" />
        <property name="Hidden" type="bool">False</property>
        <property name="Description" type="string">JCP 68 TEST</property>
        <property name="Content" type="string">
        &lt;H1&gt;HELLO THIS IS A TEST&lt;/H1&gt;
        <property name="CatalogIconImageUrl" type="string">/_layouts/images/wp_pers.gif</property>
        <property name="Title" type="string">JCP 68 </property>
        <property name="AllowHide" type="bool">False</property>
        <property name="AllowMinimize" type="bool">False</property>
        <property name="AllowZoneChange" type="bool">True</property>
        <property name="TitleUrl" type="string" />
        <property name="ChromeType" type="chrometype">None</property>
        <property name="AllowConnect" type="bool">True</property>
        <property name="Width" type="unit" />
        <property name="Height" type="unit" />
        <property name="HelpMode" type="helpmode">Navigate</property>
        <property name="AllowEdit" type="bool">False</property>
        <property name="TitleIconImageUrl" type="string" />
        <property name="Direction" type="direction">NotSet</property>
        <property name="AllowClose" type="bool">False</property>
        <property name="ChromeState" type="chromestate">Normal</property>
  • Use content editor webpart with a link to a txt file with your script Commented Apr 16, 2016 at 13:09
  • For some reason, content editor web parts are not portable like script editors.
    – Hell.Bent
    Commented Apr 16, 2016 at 15:56
  • adding some code to master page? Commented Apr 16, 2016 at 18:50

2 Answers 2


You can use similar functionality by using

  1. Content Editor Webpart
  2. Copy all the code in a text file
  3. Upload the text file somewhere on site
  4. Refer that text file in the CEWP

And you are good to go!

  • The problem with Content Editor Webparts is they are not as portable. have you ever tried to export and move the webpart between sites. Having to reconfigure Content editor webparts on each site is not ideal of us. i can send users a configured script editor web part and have them just upload to webparts. Also, site admins can still edit webpart and see the reference.
    – Hell.Bent
    Commented Apr 16, 2016 at 16:25

Save the below xml as dwp file and change the contentlink property with your script text file location, it should be portable and you don't need to configure the webpart. Add the WebPart simply to any page.

<?xml version="1.0" encoding="utf-8"?> <WebPart xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/WebPart/v2"> <Title>Rajesh Sample ContentEditor</Title> <FrameType>None</FrameType> <Description>Rajesh sample content editor webpart http://rjesh.com</Description> <IsIncluded>true</IsIncluded> <ZoneID>Header</ZoneID> <PartOrder>0</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>true</IsVisible> <DetailLink>Rajesh Sample ContentEditor</DetailLink> <HelpLink /> <HelpMode>Modeless</HelpMode> <Dir>Default</Dir> <PartImageSmall /> <MissingAssembly>Cannot import this Web Part.</MissingAssembly> <PartImageLarge>/_layouts/15/images/mscontl.gif</PartImageLarge> <IsIncludedFilter /> <Assembly>Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly> <TypeName>Microsoft.SharePoint.WebPartPages.ContentEditorWebPart</TypeName> <ContentLink xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor">../Style Library/Rajesh/template/sample.txt</ContentLink> <Content xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor"><![CDATA[ ​]]></Content> <PartStorage xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor" /> </WebPart>

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.