Section 9.9. Connecting Parts


9.9. Connecting Parts

A web part that can exchange data with another web part is called connectable . You create a connectable part by implementing one of the SharePoint connection interfaces in your web part class. Since there are two sides to any connection, there are two interfaces for each type of connection: a provider and a consumer. The interfaces are described in Table 9-5.

Table 9-5. Web part connection interfaces

Interface pair

Use to share

Example

ICellProvider ,

ICellConsumer

Single item

Form web part (cell provider), Image web part ( cell consumer)

IRowProvider ,

IRowConsumer

Row of values

List web part (row provider)

IListProvider ,

IListConsumer

List (table) of values

List web part (list provider)

IFilterProvider ,

IFilterConsumer

A list filter

Form web part (filter provider)

IParametersInProvider ,

IParametersInConsumer

Set of values as described by the web part

None

IParametersOutProvider ,

IParametersOutConsumer

Set of values as described by the web part

None


9.9.1. Creating a Simple Connection

The Web Part Templates for Visual Studio includes templates for ICellProvider and ICellConsumer web parts. To add connectable web parts to an existing web part library project:

  1. In Visual Studio, choose Project Add New Item and select the Provider Web Part template.

  2. Repeat for the the Consumer Web Part template.

  3. Build the project.

  4. Create a test web page and import the two web parts onto the page.

  5. Choose Modify Shared Page Design this Page to switch into design mode.

  6. Provides a cell to consumer web part.

The web part templates create connectable parts that share a single value through their Text property. Figure 9-16 shows provider and consumer web parts created from the templates running on a test page.

animal 9-16. Changing the Text property of the provider part to see the change in the consumer part



Essential SharePoint
Essential SharePoint 2007: A Practical Guide for Users, Administrators and Developers
ISBN: 0596514077
EAN: 2147483647
Year: 2005
Pages: 153
Authors: Jeff Webb

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net