Tuesday, September 20, 2011

SharePoint 2010: Client Object Model: Content Type Development

To Create a content type using client object model, first create new Project using Console project Template. Add refrence to Microsoft.SharePoint.Client.dll and Microsoft.SharePoint.Client.Runtime.dll asemblies. You can find tyhen at {SharePoint Root}\ISAPI folder.

SharePoint code can run externally with help of ClientContext object. The ClientContext object provides access to site collection objects.


ClientContext clientContext = new ClientContext("http://anmol-pc");
Web web = clientContext.Web;

ContentTypeCollection contentTypes = web.ContentTypes;

ContentTypeCreationInformation newConInfo = new ContentTypeCreationInformation();
newConInfo.Name = "MyFirstContentType";
newConInfo.ParentContentType = contentTypes.GetById("add parent content ID");
newConInfo.Group = "My Group";
ContentType newContent = contentTypes.Add(newConInfo);

No comments:

Post a Comment

Popular Posts