Follow in Twitter & Facebook


Like in Facebook

Powered By Blogger Widgets

Free Download

FREE Tools


Monday, August 22, 2011

How to make the content type as sealed in SharePoint 2010?

Suppose you need to design a SharePoint 2010 application that created a content type. And you need to design in such a way that users are not able to change the content type from the SharePoint 2010 user interface. To achieve this you have to make the content type as sealed and deploy as a feature.

You can do this by using SharePoint 2010 object model. Just get the particular content type and set the Sealed property to true like below.

 using (SPSite currentSiteCollection = new SPSite("URL of the site collection"))
           {

            SPContentType contentType = currentSiteCollection.RootWeb.ContentTypes["ContentTypeName"];
           contentType.Sealed = true;
           contentType.Update();
            }

Remember that you must be a administrator for the site collection to make a seal content type.
If you want to unsealed the content type then just make the Sealed to false like below.

 using (SPSite currentSiteCollection = new SPSite("URL of the site collection"))
           {
            SPContentType contentType = currentSiteCollection.RootWeb.ContentTypes["ContentTypeName"];
        contentType.Sealed = false;
           contentType.Update();
            }




0 on: "How to make the content type as sealed in SharePoint 2010?"