ProxyWebPartManager.StaticConnections Property


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Gets a collection of static connections declared within the <asp:proxywebpartmanager> element on a content page.

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

public ProxyWebPartConnectionCollection StaticConnections { get; }

Property Value

Type: System.Web.UI.WebControls.WebParts.ProxyWebPartConnectionCollection

A ProxyWebPartConnectionCollection that contains all static WebPartConnection objects declared within an <asp:proxywebpartmanager> element.

The StaticConnections property references the collection of WebPartConnection objects declared in an <asp:proxywebpartmanager> element. The connections contained in this collection are added to the static connections of the WebPartManager controls (referenced by its WebPartManager.StaticConnections collection), and treated exactly like any other connections associated with the WebPartManager control.

The declarative element that corresponds to the StaticConnections property is the <staticconnections> element. In an application that uses master pages, the <staticconnections> element is added as a child of the <asp:proxywebpartmanager> element on a content page, and an <asp:webpartconnection> element in turn is added as a child of the <staticconnections> element. Multiple <asp:webpartconnection> elements can be added to one <staticconnections> element, and multiple content pages can declare static connections as part of a master pages application.

The following code example demonstrates how to use the StaticConnections property on the ProxyWebPartManager class. This code example shows only the relevant portion of the code from the content page that declares the ProxyWebPartManager control and the static connection. For the other pages required to run the code example, and a description of how to set them up, see the Example section of the ProxyWebPartManager class overview.

The following code is the content page that declares the <staticconnections> element as a child of the <asp:proxywebpartmanager> element. Also note that the Button1_Click method checks the count of the StaticConnections property on the ProxyWebPartManager control and writes it to the page.

<%@ Page Language="C#" MasterPageFile="~/MasterPageCS.master" 
  Title="Connections Page" %>
<%@ Register TagPrefix="aspSample" 
    Namespace="Samples.AspNet.CS.Controls" %>

<script runat="server">

  protected void Button1_Click(object sender, EventArgs e)
    StringBuilder lblText = new StringBuilder();

    if (Page.Master.FindControl("WebPartManager1") != null)
      WebPartManager theMgr = 
      lblText.Append("WebPartManager:  <br /><pre>" +
        "  Master page file is " + Page.MasterPageFile + "<br />" +
        "  ID is " + theMgr.ID + "<br />" +
        "  Connection count is " +
           theMgr.StaticConnections.Count.ToString() + "<br />" +
        "  WebParts count is " +
           theMgr.WebParts.Count.ToString() + "</pre><br />");

    if (proxymgr1 != null)
      lblText.Append("ProxyWebPartManager:  <br /><pre>" +
        "  Content page file is " + Request.Path + "<br />" +
        "  ID is " + proxymgr1.ID + "<br />" +
        "  Connection count is " +
           proxymgr1.StaticConnections.Count.ToString() + 
           "</pre><br />");

    Literal1.Text = lblText.ToString();



<asp:Content ID="Content1" Runat="Server" 
  ContentPlaceHolderID="ContentPlaceHolder1" >

  <asp:proxywebpartmanager id="proxymgr1" runat="server">
      <asp:webpartconnection id="connection1" 
        providerid="zipProvider" />

  <asp:webpartzone id="zone1" runat="server">
      <aspsample:zipcodewebpart id="zipProvider" runat="server" 
        title="Zip Code Provider"  />
      <aspsample:weatherwebpart id="zipConsumer" runat="server" 
        title="Zip Code Consumer" />

  <asp:button id="Button1" runat="server" 
    text="WebPartManager Information" onclick="Button1_Click" />
  <br />


  <asp:connectionszone id="ConnectionsZone1" runat="server" />
  <asp:literal id="Literal1" runat="server" />


After you load the page in a browser, click the WebPartManager Information button and observe the information about the WebPartManager control in the master page, and the ProxyWebPartManager control in the content page. For example, note that they both have the same count in their respective properties that track static connections (the StaticConnections property).

.NET Framework
Available since 2.0
Return to top