System.Web.UI.WebControls.WebParts.ConnectionPoint Class

Serves as the base class for defining connection point objects that enable the consumer control and the provider control in a Web Parts connection to share data.

See Also: ConnectionPoint Members

Syntax

public abstract class ConnectionPoint

Remarks

Every Web Parts connection consists of two server controls sharing data: one control is the consumer, the other is the provider. For a discussion of the essential components of a Web Parts connection, and the connection object itself, see the System.Web.UI.WebControls.WebParts.WebPartConnection class overview. Every Web Parts connection requires connection points. The provider and the consumer control must each have at least one defined System.Web.UI.WebControls.WebParts.ConnectionPoint object (each of them can optionally have multiple connection points) that contains the details for how a control can connect to another control and the type of data it can share. In an actual connection, the provider has its own type of connection point object (derived from the base System.Web.UI.WebControls.WebParts.ConnectionPoint class), a System.Web.UI.WebControls.WebParts.ProviderConnectionPoint instance, and the consumer has its own object, a System.Web.UI.WebControls.WebParts.ConsumerConnectionPoint instance.

To create a provider connection point, developers must add a callback method to the provider that will return an implemented interface instance to a consumer. They must mark the callback method in the source code with a ConnectionProvider code attribute (see the System.Web.UI.WebControls.WebParts.ConnectionProviderAttribute class). Similarly, to create a consumer connection point, developers must add a method to the consumer that receives an interface instance, and they must mark that method with a ConnectionConsumer attribute (see the System.Web.UI.WebControls.WebParts.ConnectionConsumerAttribute class).

When developers create connections on a Web page, they can be created as static or dynamic connections. Static connections are declared in the markup of a Web page. When a static connection is declared, developers can designate which connection points are used for both the consumer and provider by assigning values to the ProviderConnectionPointID and ConsumerConnectionPointID attributes within the <asp:webpartconnection> element tag. This approach is especially useful if there are multiple connection points defined within the consumer and provider controls, because it enables the static connection to identify which connection points to use for the connection.

Dynamic connections are created programmatically, either by a developer's code or by users through the user interface (UI) provided by the System.Web.UI.WebControls.WebParts.ConnectionsZone control. To create a connection in code, developers must get an instance of a System.Web.UI.WebControls.WebParts.WebPartConnection object by calling the WebPartManager.ConnectWebParts(WebPart, ProviderConnectionPoint, WebPart, ConsumerConnectionPoint) method on the System.Web.UI.WebControls.WebParts.WebPartManager control. Before they can call this method, developers must have references to the consumer and provider server controls and their respective connection point objects. To get references to the connection points for a provider and a consumer control, developers first call the WebPartManager.GetProviderConnectionPoints(WebPart) and WebPartManager.GetConsumerConnectionPoints(WebPart) methods on the System.Web.UI.WebControls.WebParts.WebPartManager control. These methods return the appropriate connection point objects, which in turn can be passed to the method for creating a connection.

When the provider's and the consumer's connection point objects both work with the same type of interface, they are compatible and can form a direct connection to share data. If they do not work with the same interface type, a System.Web.UI.WebControls.WebParts.WebPartTransformer object must be used to translate the interface instance from the provider into a type that the consumer can work with.

The abstract System.Web.UI.WebControls.WebParts.ConnectionPoint class provides the base details of connection points that are shared by both consumer and provider controls. Several properties contain these details. The ConnectionPoint.AllowsMultipleConnections property indicates whether a connection point can participate in more than one connection at a time. By default, provider connection points can participate in multiple connections, and consumer connection points cannot. The ConnectionPoint.ControlType property indicates the type of the server control associated with a connection point. Note that not only System.Web.UI.WebControls.WebParts.WebPart controls can form connections; any server control, whether an ASP.NET control, a custom control, or a user control, can be enabled to participate in connections if placed in a System.Web.UI.WebControls.WebParts.WebPartZoneBase zone. The ConnectionPoint.DisplayName property provides a friendly name for the connection point that can be displayed in the UI to assist users who are creating connections. The ConnectionPoint.ID property serves as a string identifier for the connection point object itself. The ConnectionPoint.InterfaceType property indicates what type of interface instance the connection point understands. Whether a given connection point provides or consumes an instance of that interface is determined by whether it is a System.Web.UI.WebControls.WebParts.ProviderConnectionPoint or a System.Web.UI.WebControls.WebParts.ConsumerConnectionPoint object.

The System.Web.UI.WebControls.WebParts.ConnectionPoint class has one method. The ConnectionPoint.GetEnabled(System.Web.UI.Control) method returns a Boolean value indicating whether a connection point is currently able to participate in connections.

The System.Web.UI.WebControls.WebParts.ConnectionPoint class also has one public field, ConnectionPoint.DefaultID. This field contains a value used to identify the default connection point in a connection.

Note:

The attributes for specifying connection point methods have only one required parameter, displayName, so it is possible to create the default connection point attribute without specifying an ID. In such cases, the ConnectionPoint.DefaultID field supplies a base value to use.

Requirements

Namespace: System.Web.UI.WebControls.WebParts
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 2.0.0.0
Since: .NET 2.0