WebPartConnection.IsActive Property
Assembly: System.Web (in system.web.dll)
The IsActive property indicates a state of a WebPartConnection object. When the connection is in this state, the provider and consumer controls in the connection are communicating and able to exchange data through a common interface or a WebPartTransformer object.
When a user views a rendered page that includes an established connection in normal browse mode, the connection is typically active (unless it failed to be activated due to some conflict or other issue when the page loaded). In the early stages of the page and control life cycle, the property value is false. The connection is activated just after the ConnectionsActivated event on the WebPartManager control is raised. Specifically, the connection is activated after the consumer has retrieved an instance of the specified interface from the provider or a WebPartTransformer object.
It is useful to know whether a connection is active in situations where there might be conflicts or synchronization issues due to multiple connections on a page. For example, if there is some kind of conflict between two connections, the WebPartManager control has the option of not activating one of the connections to avoid the conflict.
The following code example demonstrates use of the IsActive property.
The 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 all 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 Server Control.
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. Within the <script> element are four event handlers. Each event handler checks the value of the IsActive property on the static connection, and writes a message to the Label control indicating whether the connection is active or inactive at that state of the page and control life cycle. This demonstrates at what point the connection becomes active, and that it remains active after the page is rendered.
Load the page in a browser. The static connection is already created, and messages have already been written to the labels showing whether the connection was active at various points in the page and control life cycle. Click the Connection Details button, and note that the connection is not active at that point, but that the connection is reactivated each time after the ConnectionsActivated event, and that it is still active (and will remain so) after the PreRender event of the page.
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.