TechBubbles Microsoft Technology BLOG

Creating Visual Web Parts using VS 2010 for SharePoint 2010

 

This post discusses about how to create a visual web part for SharePoint 2010 using Visual Studio 2010. Visual Web Parts can be developed on Visual Studio design surface which is as easy as drag and drop controls in asp.net application.

The web part which we are going to create is standard asp.net tree-view control which shows Interview Events and candidates who attend those interviews. We are going to use two lists from the SharePoint site and joining those two lists using LINQ.

SP2010

The two lists which we are using are Candidates list and Interviews list as shown below.

Candidates List

image

Interviews List

image

The lookup column for Interviews list is Candidate name column. We can use this column to join information from the both list and to display in visual web part.

image

As we are using LINQ to retrieve the information from SharePoint list, We can generate entity class which provides an object oriented interface to the SharePoint data. You can find the tool in Microsoft Shared/Web Server Extensions / 14 / Bin folder

image

It can generate the files in either VB or C# programming language. This can be mentioned in the command line. Now start building the Visual Web Part.

image

Create a new project in visual studio 2010 and select the project type Visual Web Part from the template dialogue box as shown below

image

Select the deploy as a farm solution option as shown below

image

Add a SharePoint LINQ dll as a reference to the project.

image

Add the entities file which we have created earlier.

image

Using the design surface you can drag and drop the web controls, Drag the tree view control to the surface.

image

Add some code to populate the nodes in Tree view control. Import the necessary namespaces to your code. Create objects for web context and data context. Now write the query to retrieve the data from SharePoint list.

image

Change the category name where you want to deploy the webpart in elements.xml file

image

To deploy the webpart to the SharePoint site just right click the project and say Deploy

image

Add the deployed web part to the page as shown below

image

The resulted webpart on the page looks as below

image

Share this post :

About the author

Kalyan Bandarupalli

My name is kalyan, I am a software architect and builds the applications using Microsoft .NET technologies. Here I am trying to share what I feel and what I think with whoever comes along wandering to Internet home of mine.I hope that this page and its contents will speak for me and that is the reason I am not going to say anything specially about my self here.

2 Comments

TechBubbles Microsoft Technology BLOG

Follow me

Archives

Tag Cloud