Learn more about SQL Server tools

mssqltips logo
 

Tutorials          DBA          Dev          BI          Career          Categories          Webcasts          Whitepapers          Today's Tip          Join

Tutorials      DBA      Dev      BI      Categories      Webcasts

DBA    Dev    BI    Categories

 
Failover Clustering in the Cloud - Understanding Your Options - Free Webinar
 

Deploying a List Definition via Visual Studio .Net 2010


By:   |   Last Updated: 2011-09-27   |   Comments   |   Related Tips: > Sharepoint

Problem

Creating a list instance from "Out of the box" predefined SharePoint lists is easy but limited. How about creating our custom list via Visual Studio .Net 2010?

Solution

List definitions and list instances that are based on those definitions are a fundamental part of Microsoft SharePoint 2010. Microsoft Visual Studio 2010 provides a project type that makes it easier to create list definitions in XML and to create list instances that are based on those definitions. In addition, tight integration with SharePoint 2010 enables you to deploy list definitions and list instances to a SharePoint site directly from Visual Studio 2010. Let's follow the below steps :

Open Visual Studio .Net 2010 > File (Menu) > New > Project  :

start page

Under Installed Templates, expand "SharePoint" and select "2010" from the left side panel. > Select "Empty SharePoint Project" from the right side panel. Type a name for your project, then click the OK button.

new project

Type the URL of your local SharePoint site at the "What local site do you want to use for debugging?" textbox and choose "Deploy as a farm solution" (Differences between Farm & Sandbox Solutions) .

customization wizard

Click on the "View" menu > Solution Explorer > right-click at the created solution > Add > New Item :

solution explorer

Select "2010" for SharePoint under "Installed Templates" from the left side panel > select "List Definition" from the right side panel :

online templates

Keep/Edit the display name of the list definition , Select "Custom List" as the type of the list definition and check "Add a list intance for this list definition":

choose list definition settings

As seen below is our solution with the created custom list definition and added list instance.

solution explorer

Right click at "ListDefViaVS2010" project then select "Deploy" in order to deploy our solution to the SharePoint site then wait till we check that the output is successfully deployed:

deploy
output

Now let's go to the SharePoint site to check the deployed custom list definition , Click "Site Actions" menu then "View All Site Content":

site actions

As we can see below a new added list instance to our custom list definition "ListDefViaVs2010 - ListInstance1".

content and structure reports
Next Steps


Last Updated: 2011-09-27


next webcast button


next tip button



About the author





Post a comment or let the author know this tip helped.

All comments are reviewed, so stay on subject or we may delete your comment. Note: your email address is not published. Required fields are marked with an asterisk (*).

*Name    *Email    Email me updates 


Signup for our newsletter
 I agree by submitting my data to receive communications, account updates and/or special offers about SQL Server from MSSQLTips and/or its Sponsors. I have read the privacy statement and understand I may unsubscribe at any time.



    



Learn more about SQL Server tools