.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Melody Anderson

Home >> Articles >> SharePoint >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Create Site Definition with List Instance in SharePoint

Posted By:Jean Paul       Posted Date: December 31, 2014    Points: 200    Category: SharePoint    URL: http://www.dotnetspark.com  

In this article we will explore a real-world scenario of Site Definition creation with List Instance. The source code is associated with this article.

In this article I will take you through a real-world scenario.

1. You need to create a Site Definition

2. When user creates a new site from this Site Definition, a new List Instance too be created

What is the Solution?

We can have multiple solutions for this:

1. Use Feature Stapling

2. Use Event Handler

3. Use Site Definition

I would recommend the third approach as it is the shortest path.


Following are the steps involved for the solution:

1. Create SharePoint Solution Project

2. Create Site Definition

3. Create List Definition

4. Include List in Site Definition

5. Deploy

6. Test

Step 1: Create SharePoint Solution Project

Run Visual Studio 2012 & create a new SharePoint project.


Choose the Farm Solution option as shown below.


Step 2: Create Site Definition

Choose Solution > Add new item > Site Definition


Enter a name for the site definition.

Step 3: Create List Definition

Add a new item > List


Enter a name for the list instance. Choose the option custom and click the Next button of wizard.

(the custom option allows you to create new fields, view fields etc.)


Click the Finish button & in the appearing page enter some unique fields for the list.


Step 5: Include List in Site Definition

Open the onet.xml of Site Definition & Reference the list from it.


You need to use the correct Template Id & Feature Id for it.


For finding feature id, open the Features > Feature 1 > .feature file > Find the GUID against featureId

Step 5: Deploy

Build & Deploy the solution

Now you are ready to test the Site Definition.

Step 6: Test

Open the Browser > Open SharePoint site > Site Contents > New Sub site


After creating the site > Go to Site Contents & you can see the List Instance there.


This concludes our Site Definition with List Instance creation.


A good read for Site Definition vs. Site Templates

ยท link




In this article we have explored a real-world scenario of Site Definition creation with List Instance. The source code is associated with this article.

 Subscribe to Articles


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend