Gets or sets the property value on a connection that references the ID of the object serving as the consumer connection point for that connection.
Assembly: System.Web (in System.Web.dll)
For a static connection declared in the markup of a Web page, developers can specify which consumer connection point will be used for the connection by assigning a value to the ConsumerConnectionPointID attribute on the <asp:webpartconnection> element. If a value is not assigned to the attribute, the DefaultID property value is used.
When you create dynamic (programmatic) connections, normally you should not set the value of the property. You can simply call the ConnectWebParts method on the WebPartManager control, passing to it the consumer and consumer connection point objects (along with the other required parameters), and that method determines the correct ID to use for the consumer's connection point. Similarly, when you disconnect, you can call the DisconnectWebParts method without needing to specify the property value.
The ID of a consumer's connection point can be determined when you designate a WebPart or other server control as a consumer. You must identify a method in the consumer that retrieves an instance of an interface furnished by either a provider control or a transformer. To identify the method, mark it with the ConnectionConsumer code attribute. When you add this attribute, you can add an optional string value parameter that serves as an ID for the consumer's ConsumerConnectionPoint object. If you supply a value for the optional ID parameter, that value becomes the value of the property for the connection. If you do not supply an ID value, the DefaultID property value is used.
The following code example shows the declarative and programmatic use of the 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.
The second part of the code example is the source code for the interface, and the consumer and provider controls. 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 Web page. Note that a connection is declared in the page markup, using the <StaticConnections> and <asp:WebPartsConnection> elements. The connection declaration includes the required ConsumerConnectionPointID attribute. A second method for creating the connection appears in the Button1_Click method, where the code creates a new connection, using the connection point defined in the consumer control. Then, in the Button2_Click method, the code accesses the property.
After you load the page in a browser, a connection already exists because of the static connection declared in the page. Enter some text in the provider control, and note that it is displayed in the consumer due to the connection. Next, disconnect the controls. Using the Display Mode drop-down list control, 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. Click the Disconnect button. Use the Connect WebPart Controls button to recreate a connection between the two controls. Click the ConnectionPoint Details button to run the code that accesses the property value. The value is written out in a label below the controls.
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.