• USA : +1 973 910 5725
  • INDIA: +91 905 291 3388
  • info@tekslate.com
  • Login

Creating Connectable Web Parts using SharePoint 2010 Visual Web Part.

Here we are going to use Visual Web Part template to create Connectable Web parts. In ASPNET the Web Parts are communicated via interfaces this allows Web Parts to exchange information with each other at run time.  These Interfaces will define the message structure which is passed between two connectable Web Parts.

Here are the steps we need to do to create a Connectable web parts.

  1. Define the Interface that will specify the data we wanted pass or exchange from one web part to another web part.
  2. Create Provider Web Part.
  3. Consumer Web Part.

First Fire of VS.NET 2010 and create Empty SharePoint project.

 

18

Now Visual studio provides you to select Deployment options.  Here we are going with Farm based solution. Because Visual Web part cannot be deployed in Sandboxed solution.

19

If you select Sandboxed solution and deploy to SharePoint you get the following error

 

20

 

Now we need to add the Interface to our project. Here I am calling it  ICommunicationChannel.

public interface ICommunicationChannel
{
int GetInvoiceId { get; }
}

Now we need to Add both Provider & Consumer Visual  Web Parts .

In provider web part UI just add Dropdown list box.

21

 

Now add Consumer web part UI just add GridView control.

 

22

Now open of the Provider Web part and add our Interface to implement as shown here.

23

 

Now open of the Consumer web part and add method to receive Provider Web Part message.

24

I am using LINQ to SQL to connect my Data Source. Invoice and Invoice Line are tables from my Database.

 

25

Interested in mastering SharePoint Training? Enroll now for FREE demo on SharePoint Training Course.

Now we need to populate the drop down List box with Invoice ID’s from our Database table called Invoice Line.

26

In consumer web part we need to Query the Invoice Details information for the Invoice ID passed by Provider web part. [Which is selected in Provider web part drop down list].

27

 

Now build the project correct it if any compiler errors and then deploy to SharePoint. Now go to the SharePoint site where you wanted add this web parts and test.

Click Edit -> Insert and select Web Part button from the Ribbon menu now select Custom from Categories ->select Provider web part-> click add button this will adds provider web part to the Page. Follow the same steps to add Consumer Web Part as well.

28

 

Once Both Provider and Consumer web parts are added to the Page now we need to establish the connection between these two web parts.  To do click Edit Web Part on Provider web Part you will see the connections and select Consumer web Part as shown below.

 

29

 

Here is the result of Connectable Web Parts.

30

 

Create a Sample Project Task List in SharePoint 2010

 

This exercise requires a list named Projects on the local SharePoint 2010 Web site specified later in this article. The list should contain the fields shown in Table 1. To create this list, follow these steps:

To create the Project Task List

  1. Open the SharePoint 2010 Web site that you want to add the Web Parts to (such as http://localhost/sites/SampleWebPartSite) in Internet Explorer.
  2. Click Site Actions, click More Options, and then click Custom List.
  3. In the Name box, type Projects and then click Create.
  4. On the List Tools tab, click List, and on the Manage Views group, click Modify Views.
  5. Clear all Column Name options and then select the ID and Title Click OK.
  6. Click Add new item and add the information in the first row (ignore the header row) of Table 1. The ID fields updates automatically.

 

Title
Writing more sample code
Writing more developer tools
Answering forum questions
Writing developer articles

 

  1. Repeat step 6 for the remaining rows of Table 1.

For Indepth understanding of SharePoint click on

Summary
Review Date
Reviewed Item
Creating Connectable Web Parts using SharePoint 2010 Visual Web Part
Author Rating
5

“At TekSlate, we are trying to create high quality tutorials and articles, if you think any information is incorrect or want to add anything to the article, please feel free to get in touch with us at info@tekslate.com, we will update the article in 24 hours.”

0 Responses on Creating Connectable Web Parts using SharePoint 2010 Visual Web Part."

    Leave a Message

    Your email address will not be published. Required fields are marked *

    Site Disclaimer, Copyright © 2016 - All Rights Reserved.

    Support


    Please leave a message and we'll get back to you soon.

    I agree to be contacted via e-mail.