Here we are going to use the 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 Connectable web parts.
Aspired to become a SharePoint? Explore the post to discover the know-how on the " SharePoint Training" course
First Fire of VS.NET 2010 and create an Empty SharePoint project. Now Visual studio provides you to select Deployment options. Here we are going with Farm based solution. Because the Visual Web part cannot be deployed in the Sandboxed solution. If you select a Sandboxed solution and deploy to SharePoint you get the following error 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 the provider web, part UI just add the Dropdown list box. Now add the Consumer web part UI just add GridView control. Now open of the Provider Web part and add our Interface to implement as shown here. Now open of the Consumer web part and add a method to receive the Provider Web Part message. I am using LINQ to SQL to connect my Data Source. Invoice and Invoice Line are tables from my Database.
Now we need to populate the drop-down List box with Invoice ids from our Database table called Invoice Line. In the consumer web part we need to Query the Invoice Details information for the Invoice ID passed by the Provider web part. [Which is selected in the Provider web part drop-down list]. Now build the project correct it if any compiler errors and then deploy to SharePoint. Now go to the SharePoint site where you wanted to add these web parts and tests. 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 add the provider web part to the Page. Follow the same steps to add the Consumer Web Part as well. 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. Here is the result of Connectable Web Parts.
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:
Title |
Writing more sample code |
Writing more developer tools |
Answering forum questions |
Writing developer articles |
You liked the article?
Like : 0
Vote for difficulty
Current difficulty (Avg): Medium
1/3
TekSlate is the best online training provider in delivering world-class IT skills to individuals and corporates from all parts of the globe. We are proven experts in accumulating every need of an IT skills upgrade aspirant and have delivered excellent services. We aim to bring you all the essentials to learn and master new technologies in the market with our articles, blogs, and videos. Build your career success with us, enhancing most in-demand skills in the market.
Stay Updated
Get stories of change makers and innovators from the startup ecosystem in your inbox