WebPartConnection.ProviderID Property

 

Gets or sets the property value on a connection that references the ID of the WebPart control acting as a provider for that connection.

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

member ProviderID : string with get, set

Property Value

Type: System.String

A string that contains the ID of the provider control.

The ProviderID property value is required when you create a connection between two WebPart controls. If a value is not assigned to the property, an exception is thrown when the WebPartManager control attempts to activate the connection.

The following code example shows the declarative and programmatic use of the ProviderID 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 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.

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

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 ProviderID 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 value of the ProviderID property and displays it in a label.

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

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. To do that, 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. Click the Disconnect button, and the controls are disconnected. Next, use the Connect WebPart Controls button to recreate a connection between the two controls. Click the Consumer Details button to run the code that accesses the ProviderID property value.

.NET Framework
Available since 2.0
Return to top
Show: