Definition of a Connection Interface

The Web Part infrastructure provides rich support for communication between Web Parts. Developers can use standard interfaces to create Web Parts that can exchange information with each other. For example, a Web Part that implements the ICellConsumer interface can receive information from a Web Part that implements the ICellProvider interface. Users can then connect Web Parts to each other using simple menu commands in the browser.

Interfaces are a grouping of events relevant to a specific item such as a row in a list. A part raises an interface event to one or more connected parts to initiate an action. For information about the standard pairs of interfaces for creating connectable Web Parts, see Interface Pairs for Connectable Web Parts.

Connection interfaces can be implemented inside a Web Part, or in any class that is not a Web Part, as long as you register the interface in the Web Part using the RegisterInterface method, passing in the object that implements the particular connection interface. The most common scenario for creating such a Web Part is when the Web Part needs to be both a provider and consumer. For example, a Web Part that displays a list of data may want to allow filtering the list as well as providing a row from it. The best way to achieve this is to create separate classes that implement the different interfaces—in this example, the IRowProvider and IFilterConsumer interfaces. Within the RegisterInterface method of the main WebPart class, the classes that implement the interfaces can be instantiated and registered separately.

The Connections property of the WebPart class contains the connection information that is stored with a connected Web Part.

For a detailed description of the steps necessary to implement a Web Part with connection interfaces, including the methods and events that must be overridden, see Creating a Connectable Web Part. For an example of how to create a connectable Web Part that supports multiple interfaces, see Creating a Connectable Web Part That Supports Multiple Interfaces.