Search This Blog

Wednesday, December 24, 2014

Creating Custom Content Type for SharePoint List in Visual Studio 2010

Introduction

Site columns and content types are the fundamental elements of SharePoint. Content type is the core organizational feature of SharePoint 2010. They are designed to give ability to organize the SharePoint contents in a centralized and meaningful manner. Both the site columns and content types are reusable since they are independent of sites and lists. 


Content type is not same as file type. One file type could contain multiple content types such as 'Resume', 'Business Plan', 'Policy Document', 'Patient Record' etc. Content type is all about the extra information you need to know. Rather than having a generic document, with little bit of work we can create a content type to represent 'Resume', 'Products' etc. So that these documents are treated as different with extra information. But how do we do that? Content type is not a complex ones it all about meta data. Thought of writing article on this. This article explains the creation of custom content type for SharePoint list in Visual Studio 2010. I have used the custom field items which I have created in my previous article 'Creating Custom Field Items for SharePoint List in Visual Studio 2010' to this custom content type.

Implementation Steps
  • Open Visual Studio 2010 and click on 'New Project' option.
  • Select 'Empty SharePoint Project' in the template pane and change the name of the project that you would like to have it.

  • Specify the site and security level for debugging.
  • Select trust level as 'Deploy as a farm solution'. You can select trust level as 'Deploy as a sandboxed solution' option also.
  • Click 'Finish'. You should see project in the solution explorer.
  • Right click on solution explorer and then click on 'Add New Item' option.
  • Select 'Content Type' from the template pane.

  • Choose the base content type as 'Item' from the dropdown list.



    That's it. Compile the project and deploy the solution.

Verification Steps
  • Go to SharePoint site.
  • Go to Site Actions -> Settings
  • Select 'Site Content Types' option under 'Galleries' section.

  • You can see 'Employee Content Type' created above. Click on 'Employee Content Type' link. This will show you the field items associated to content types.






No comments:

Post a Comment