This documentation is archived and is not being maintained.

WebPartConnection::Provider Property

Gets a WebPart control that acts as the provider in a Web Parts connection.

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

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

Property Value

Type: System.Web.UI.WebControls.WebParts::WebPart
A WebPart that acts as the provider of data.

ExceptionCondition
InvalidOperationException

The length of the ProviderID property value is zero.

Every Web Parts connection consists of two WebPart controls--a consumer and a provider--and the Provider property returns a reference to the provider control in a connection.

Like its counterpart in a connection (the consumer control), the provider control is required to establish a connection. Whether you create the connection programmatically, or by declaring it in page persistence format, you must specify a control to act as the provider for a connection.

The following code example demonstrates use of the Provider property.

The code example has three parts:

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

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

  • An explanation of how to run the example page.

The first 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 second part of the code example is the Web page. Near the top is a Register directive that refers to the source code for the two dynamically compiled WebPart controls. The static connection is declared within the <StaticConnections> element on the page. Notice that in the <asp:webpartconnection> element, the ProviderID attribute has the ID of the provider control assigned to it. This is required to identify the provider for the static connection. The Button1_Click method accesses the Provider property and writes some of its details to a label.

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

Load the page in a browser. The static connection is already created. Enter some text in the provider control, and note that the text is displayed in the consumer control. Click the Provider Details button to display some of the property values accessed through the Provider property.

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Show: