Export (0) Print
Expand All

WebPartManager.ConnectWebParts Method

Creates a connection between two WebPart controls (or other server controls capable of forming connections) that reside in a WebPartZoneBase zone.

This member is overloaded. For complete information about this member, including syntax, usage, and examples, click a name in the overload list.

  NameDescription
Public method ConnectWebParts(WebPart, ProviderConnectionPoint, WebPart, ConsumerConnectionPoint) Creates a connection between two WebPart or GenericWebPart controls using only the references to the controls and their specified ConnectionPoint objects.
Public method ConnectWebParts(WebPart, ProviderConnectionPoint, WebPart, ConsumerConnectionPoint, WebPartTransformer) Creates a connection between two WebPart or GenericWebPart controls using the references to the controls, their specified ConnectionPoint objects, and a WebPartTransformer object.
Top

The ConnectWebParts method forms a connection between any two WebPart controls that can be connected. Before calling this method to create a connection, you might also want to call the CanConnectWebParts method in a conditional check to ensure that the controls meet the requirements for forming a connection.

NoteNote

It is also possible to create a connection between two server controls that are not WebPart controls. In general, the two controls would have to be custom server controls (for example, controls that inherit from WebControl or existing ASP.NET server controls) so that you could add the required members. The controls would also have to meet the requirements specified below.

Any type of connection scenario between two controls must meet the following requirements to be able to connect:

  • Each control resides in a WebPartZoneBase zone (it does not have to be the same zone).

  • As implemented in the Web Parts control set, the provider control in a connection implements an interface as a public method that serves as a callback to the provider, and has a ConnectionProvider metadata attribute on the method to identify it as a provider connection point. Because the GetProviderConnectionPoints method that retrieves provider connection points is virtual, a derived WebPartManager control does not necessarily have to use the same metadata attribute.

  • As implemented in the Web Parts control set, the consumer control in a connection also has a special method that enables it to get a reference to the interface that is exposed in the provider's callback method, and the consumer has a ConnectionConsumer metadata attribute on the method to identify it as a consumer connection point. Because the GetConsumerConnectionPoints method that retrieves consumer connection points is virtual, a derived WebPartManager control does not necessarily have to use the same metadata attribute.

  • The callback methods must either be compatible, in that the consumer can use the type of interface supplied in the provider's callback method (meaning that the consumer and provider can share data directly), or the developer must use a WebPartTransformer object to transform the data from the provider into a form that the consumer can use.

    Important noteImportant

    When you do not need a transformer, use the ConnectWebParts(WebPart, ProviderConnectionPoint, WebPart, ConsumerConnectionPoint) method overload. When you need a transformer, use the ConnectWebParts(WebPart, ProviderConnectionPoint, WebPart, ConsumerConnectionPoint, WebPartTransformer) method overload.

Community Additions

ADD
Show:
© 2014 Microsoft