Scenario:
You want to add Content Type programatically
Solution:
SharePoint Object Model
Code:
using (SPSite site = new SPSite("http://localhost")) {Article:
using (SPWeb web = site.OpenWeb()) {
SPContentType baseType = web.AvailableContentTypes["Document"];
SPContentType proposal = new SPContentType( baseType, web.ContentTypes, "Project Proposal");
proposal.FieldLinks.Add(new SPFieldLink(web.AvailableFields["Author"]));
web.ContentTypes.Add(proposal);
}
}
0 comments:
Post a Comment