Jan 27, 2012

Contentype in Sharepoint 2010 using visual studio 2010 - First Part

Hello guys ...
Today we will work with content types in SharePoint 2010 using visual studio 2010.

First Part we will develop a content type using visual studio 2010.
In Second part how will use the developed content type .

shall we start now.........

here we go..

I will inherit from parent document content type and associate with the document library.

Create a project with the template type Content Type.

Give Project Name here it is with my name DevendraContenType 

Deploy as Form solution.

Click on Next.
Select the content type which you need to Inherit from.
Here I am selecting as Document content type.

Click Finish.It will show the below project structure.

I want to add the field called Grade to the content type.
This is of choice type. and choice values are GradeA,GradeB,Grade C and Grade D.

I need to generate a schema for the field like below.

  Grade A+
    Grade A+
    Grade A
    Grade B+
    Grade B
    Grade C

one of easy way to achieve this is.....

To create field schema I am using list called Devendra. Go to list setting page.Click on create column.

Create column called Grade. This is of choice type. Enter few values.
Grade C
Grade D

Open SharePoint Manager 2010. And open the site then under List section got to fields section .Check for the Grade field

Click on Schema Xml. And copy the content

Open elements.xml file from the solution which is under ContentType1.Add the Fieldref tag also. Change the Name and Group properties under Countertype tag section to required values.

Click on the feature1 to change the Title and description.
Right click on the project and deploy the solution.

You can observe what are steps happening in the output window.

After deployment we need to check the content type deployed properly or not.
Click on Site Actions-> site settings
Under Site Collection Administration: Click on Site collection Features

See the below site collection feature is already activated

Click on Site Actions-> site settings

Under Galleries: Click on Site Content Types

we are done with it.You can see the Group name and the content type.

Congratulations... you have developed a content type in sharePoint 2010 using Visual studio 2010.
we will see in second part how to use the content type which you developed just now.

SharePoint-Journey for Administrators, Developers and users

No comments:

Post a Comment