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)) { Console.WriteLine(scontentid); Console.WriteLine(cId); } }} }
No comments:
Post a Comment