Sunday, May 27, 2012

how to get the content type id in sharepoint 2010

Here in this post we will describe how to get content type id in share point.The Content type ID is used for identify the content type and which hold the parent parent content type.Using this one we can get the child content id and inherit the content types from parent to child.
using (SPSite ssite = new SPSite(url))
{using (SPWeb sweb = ssite.OpenWeb())
{SPContentTypeId scontnentId = SPBuiltInContentTypeId.Document;
foreach (SPList slist in sweb.Lists)
{SPContentTypeId cId = slist.ContentTypes.BestMatch(scontentId);
if (scontentId.IsParentOf(cId))

No comments: