This documentation is archived and is not being maintained.

WebPartConnection::ConsumerConnectionPoint Property

Gets the object that serves as a connection point for a control that is acting as a consumer in a connection.

Namespace:  System.Web.UI.WebControls.WebParts
Assembly:  System.Web (in System.Web.dll)

[BrowsableAttribute(false)]
public:
property ConsumerConnectionPoint^ ConsumerConnectionPoint {
	ConsumerConnectionPoint^ get ();
}

Property Value

Type: System.Web.UI.WebControls.WebParts::ConsumerConnectionPoint
A ConsumerConnectionPoint associated with the consumer control in a connection.

One of the required steps for creating a connection between two WebPart controls is to create connection points for each control. The consumer connection point is an object that contains the information about how to connect to the control acting as a consumer. In the consumer's source code, one of the methods must be identified with the ConnectionConsumer attribute. The ConsumerConnectionPoint object that is associated with a consumer control contains details about the method and the attribute, including an ID for the method, a display name for use in the user interface (UI), and what type of interface the method can retrieve. This set of information about the consumer, its method for forming connections, and the type of interface it understands, collectively forms a consumer connection point.

By default, a ConsumerConnectionPoint object can connect to only one ProviderConnectionPoint object at a time. A consumer could have multiple methods identified as possible consumer connection points, but a consumer can only participate in one connection as a consumer (hence, only one of its consumer connection points can be active) at a time. In contrast, a ProviderConnectionPoint can connect to any number of ConsumerConnectionPoint objects. This default behavior can be changed by overriding the AllowsMultipleConnections property on the ConnectionConsumerAttribute attribute.

The following code example demonstrates the programmatic use of the ConsumerConnectionPoint property.

The example has four parts:

  • A user control that enables you to change the Web Parts display mode on a page.

  • Source code for an interface and two WebPart controls acting as the provider and the consumer for a connection.

  • A Web page to host all the controls and run the code example.

  • An explanation of how to run the example page.

The first part of this code example is the user control that enables users to change display modes on a Web page. Save the following source code to an .ascx file, giving it the file name that is assigned to the Src attribute of the Register directive for this user control, which is near the top of the hosting Web page. For details about display modes and a description of the source code in this control, see Walkthrough: Changing Display Modes on a Web Parts Page.

No code example is currently available or this language may not be supported.

The second part of the code example is the source code for the two WebPart controls that serve as the consumer and the provider for the connection, and an interface used for the connection points. For the code example to run, you must compile this source code. You can compile it explicitly and put the resulting assembly in your Web site's Bin folder or the global assembly cache. Alternatively, you can put the source code in your site's App_Code folder, where it will be dynamically compiled at run time. This code example uses dynamic compilation. For a walkthrough that demonstrates how to compile, see Walkthrough: Developing and Using a Custom Web Server Control.

No code example is currently available or this language may not be supported.

The third part of the code example is the code for the Web page that hosts the controls and demonstrates the use of the ConsumerConnectionPoint property. In the Button1_Click method, all the objects required to form a connection are created, including a ConsumerConnectionPoint object. These objects are all passed to the ConnectWebParts method to create the connection. In the Button2_Click method, the code accesses the ConsumerConnectionPoint property and displays some details of the connection point.

No code example is currently available or this language may not be supported.

After you load the page in a browser, use the Display Mode drop-down list control to switch the page to connect mode. Click the verbs menu (represented by the downward arrow in the title bar) on one of the WebPart controls, and click the connect verb. Use the Connect WebPart Controls button, or the provided connection UI, to create a connection between the two controls. Click the ConnectionPoint Details button to run the code that demonstrates the ConsumerConnectionPoint property.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0
Show: