In this post you will learn how to develop site columns using visual studio 2010 which will be used across the sites inside the site collection level. You can read more about columns in SharePoint here.
Let's start developing site columns by
To create site columns using visual studio, we need to develop solution using empty project using SharePoint 2010 template. Please see the below screenshot. In this example we name our Project as "SiteColumn".
Once you click Ok, from the above screen a wizard will start, in this you need to enter the site url which you wanted to debug and Select the SharePoint solution as a Farm solution and Click on Finish.
The next step is, create a folder called Fields in the project. We are going to add our field to this folder.
Now Right click on the folder Fields and click Add -> New Item and select Empty Element.
Once you have completed the above steps, the project structure will look like below.
Now it's time to work with an Elements.xml file to create the site columns which are required. We will take the help of SharePoint manager 2010 tool to create the fields. This tool is available on codeplex. http://spm.codeplex.com/releases/view/97332.
You will come to know how SharePoint manager helps here. First create the columns in a test site which you wanted to develop using visual studio.
Open the SharePoint manager and access the fields details in that list from the test site and select the respective field and click on the Schema Xml tab, copy that and paste in the Elements.xml file of your project. And if anything you wanted to change then change according to your requirement.
See the below Elements.xml file which we have added to our project.
Please see the below feature where i am using site(Site Sollection) as a scope.
You are ready to deploy the solution. See the below output window for activities happening while deploying the solution.
If you observe in the last activity in the output window(Refer above screenshot) is activating the feature but if you do not want to activate the feature on deployment then change the "Active Deployment Configuration" property to "No Activation".
Once you set then if you try to deploy again it will not activate the feature.Please see the below screen.
In this post you have learned how to develop a site column using visual studio 2010. You have also used SharePoint manager to get the schema of the list column and the importance of Active Deployment Configuration property in visual studio.
Devendra Velegandla is a five-time recipient of Microsoft's Most Valuable Professional (MVP) award (2014-2019) for Office Apps and Services, Office Servers and Services MVP and SharePoint Server. He received the MCC award for his contributions in Microsoft MSDN/TechNet forums. He loves sharing articles, videos, and tutorial on SharePoint and Office 365.