SIGN UP MEMBER LOGIN:    
ARTICLE

How to create custom SharePoint 2010 Content Type using Visual Studio 2010

Posted by Vijai Anand Articles | SharePoint November 19, 2010
In this article we are going to create custom Content Type using visual studio 2010.
Reader Level:

In this article we are going to create custom Content Type using visual studio 2010.

Steps Involved:

Creating Empty SharePoint Project:
  • Open Visual Studio 2010. 
  • Go to File => New => Project. 
  • Select 2010 from the installed templates SharePoint and choose Empty SharePoint Project. 
  • Name it as CustomContentType.

    1.gif

  • Click Add. 
  • Enter the SharePoint server farm URL. 
  • Select 'Deploy it as a Farm Solution". 
  • Click Finish.
Adding Content Type:
  • Right click the Solution Explorer and select Add a new item. 
  • Select Content Type from the installed templates SharePoint and name it as CustomContentType.

    2.gif

  • Choose the base content type from which our custom content type should inherit, I have chosen "Item" as a base content type.

    3.gif

  • Double click the Elements.xml file.

    4.gif

  • Replace the code with the below one.

    <?
    xml version="1.0" encoding="utf-8"?>
    <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
      <!-- Parent ContentType: Item (0x01) -->
      <ContentType ID="0x0100eb248db87d3f40efa20cdfae86fe0b50"
                   Name="Custom Content Type"
                   Group="Custom Content Types"
                   Description="My Content Type"
                   Inherits="TRUE"
                   Version="0">
        <FieldRefs>
        </FieldRefs>
      </ContentType>
    </Elements>
  • In the above code, we are adding a Custom Content Type  with the group name as "Custom Content Types". 
  • Build the solution. 
  • Deploy the solution.
Testing:
  • Go to the SharePoint site. 
  • Go to Site Actions => Site Settings =>Galleries =>Site Content Types.
  • You will see the Custom Content Type that we have created in the group "Custom Content Types".

    5.gif

Login to add your contents and source code to this article
share this article :
post comment
 
Team Foundation Server Hosting
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
Become a Sponsor