• Now Online : 32
  • admin@codemyne.net


In SharePoint web parts can be connected where data from one web part can be utilized in another web part. For an instance selecting a product from a list showing products will display the corresponding product details in another web part. This implementation can be taken any complex level like selecting a store name in a web part will display the store locations in the country map on the second web part where the store name is passed to the next web part containing the map.

This methodology is shown in the current illustration where the web part-1 or provider web part will show two text boxes for user first name and last name and the second web part will display the user full name on the click of a button.


  • Create an empty SharePoint project
  • Specify the URL of the site for which you want these web parts to use for.
  • Choose the option deploy as form solution
  • Now add an interface to the solution which exposes only the properties that the consumer web part should have access for.

Add the first web part to the solution which will be our provider webpart. This class should inherit from the System.Web.UI.WebControls.WebParts.Webpart and implement the Interface ICustomer.

In order to design the UI you need to override the method CreateChildControls () and render the control you need on the page in this method.


Now we have to render the contents on to the UI by overriding the method Rendercontents


Here the two text boxes and the button is rendered to the O/P
Now the next part is to implement the Interface


Create a method that returns the current webpart instance converted to its Interface type. So when we try to connect the webparts the provider looks for consumers which accept this return type as a parameter which I will explain in the next steps.
This method should have the [connectionprovider] attribute applied to it.

Next step is to add a consumer webpart to the solution and should also inherit from the namespace System.Web.UI.WebControls.WebParts.Webpart. Then you need to declare a variable of the interface type ICustomer cust and then follow the code as shown


You need to over ride the CreateChildControls method when ever you follow this method of manually rendering the controls.
The method ConsumeConsumer accepts the parameter Icustomer which the provider webpart returns thus the provider webpart finds its consumer.
The RenderContents method needs to be Overridden to write the output to the UI on the web part.
Finally the solution items will appear as shown with the provider and consumer in the same webpart:


For shareporint 2007, you have to perform an extra step of signing the assembly and provide the URL of the sharepoint site in the Debug tab of the project properties.
The coding part is done so now deploy the application.

Steps to be performed in the Sharepoint site to connect the web parts:
Next in the share point site -> go to site actions -> choose Edit page
Click on the add web part link of the empty webpart space and locate the web parts from the Miscellaneous section as shown.


Then from the smart tag of the provider web part choose Connections -> Send Customer To and choose Consumer Web Part.


Comments/Suggestions are invited. Happy coding......!

Comments Post a Comment