Gets a WebPart object that is acting as the consumer control in a connection.
Assembly: System.Web (in System.Web.dll)
Every Web Parts connection consists of two controls that share data. One control acts as the provider of data, and the other control acts as a consumer, receiving and processing the data from the provider. The property gets a reference to the WebPart control acting as a consumer in a connection relationship.
The following code example demonstrates the programmatic use of the property.
The code 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.
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.
The third part of the code example is the code for the Web page that hosts the controls and demonstrates the use of the property. Near the top of the page are the Register directives for the user control and the custom controls. Because this example uses dynamic compilation, the Register directive for the source file does not need to reference an assembly name; it includes only an arbitrary tag prefix and the namespace of the controls. In the Button2_Click method, the code accesses the connection object through the WebPartManager control, and gets a reference to the consumer control.
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 user interface (UI), to create a connection between the two controls. Click the Display Consumer Info button to run the code that demonstrates the property.
Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.