WebPartManager.ConnectDisplayMode Field
Assembly: System.Web (in system.web.dll)
The ConnectDisplayMode field references a custom WebPartDisplayMode object that is created and contained by the WebPartManager control. Because this is a static object, you can refer to it directly through the WebPartManager class without needing an instance of the control.
When users want to manage connections between WebPart controls on a Web page, if a ConnectionsZone zone has been declared on the page, they can switch the page into the ConnectDisplayMode mode. The connect display mode displays a special UI for managing connections, which includes the ability to connect or disconnect controls, and to edit the details of existing connections.
If you want to provide users with the ability to manage connections with the UI provided by the Web Parts control set, you must declare an <asp:connectionszone> element in the markup of a page. Unlike the elements for the other types of WebZone zones, you do not need to add any other tags within this element; you simply declare the element by itself.
The following code example demonstrates the usage of the ConnectDisplayMode mode.
The code example has three parts:
-
A source file that contains an interface and custom WebPart controls that can form a connection.
-
A Web page that provides a connection UI and demonstrates working with the ConnectDisplayMode mode.
-
An explanation of how to run the example.
The first part of the code example is a source file that contains an interface and two custom WebPart controls that are designed so they can be connected. 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 the dynamic compilation approach. For a walkthrough that demonstrates how to compile, see Walkthrough: Developing and Using a Custom Server Control.
The second part of the example is a Web page that hosts the custom controls. Within the server <script> tags on the page are several methods that populate a drop-down list with the display modes available on the page. A user can select these from the drop-down list to change the page's display mode. One of the available display modes is connect display mode, because an <asp:connectionszone> element is declared in the page's markup. Notice that this element does not contain any other child elements; it exists only to enable the connection management UI for users.
The ConnectDisplayMode mode appears in this example in two places. First, in the Page_Init method, the connect display mode is added to the drop-down list of display modes, as the code loops through the collection referenced in the SupportedDisplayModes property. Second, the Page_PreRender method checks the current display mode on the page, and if the current mode is ConnectDisplayMode, a message is displayed in a Label control.
After you load the page in a browser, click the drop-down list and select Connect to switch the page into connect display mode. Notice that a message appears, telling you that the page is in connect display mode. Now click the verbs menu (an arrow symbol) in the title bar of one of the WebPart controls, and then click Connect in the verbs menu. After the connection UI is displayed, click the link to create a connection. Use the drop-down list within the connection UI that appears, select the other control that will participate in the connection, and click the Connect button. The connection is established. Click the Close button, and then use the drop-down list at the top of the page to return the page to browse display mode.
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.