Export (0) Print
Expand All

ProxyWebPartManager.StaticConnections Property

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 */
public ProxyWebPartConnectionCollection get_StaticConnections ()

public function get StaticConnections () : ProxyWebPartConnectionCollection

Not applicable.

Property Value

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 = 
        (WebPartManager)Page.Master.FindControl("WebPartManager1");
      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();
    
  }
  
</script>

<asp:Content ID="Content1" Runat="Server" 
  ContentPlaceHolderID="ContentPlaceHolder1" >
 
  <asp:proxywebpartmanager id="proxymgr1" runat="server">
    <staticconnections>
      <asp:webpartconnection id="connection1" 
        consumerconnectionpointid="ZipCodeConsumer"
        consumerid="zipConsumer"
        providerconnectionpointid="ZipCodeProvider" 
        providerid="zipProvider" />
    </staticconnections>    
  </asp:proxywebpartmanager>

  <div>
  <asp:webpartzone id="zone1" runat="server">
    <zonetemplate>
      <aspsample:zipcodewebpart id="zipProvider" runat="server" 
        title="Zip Code Provider"  />
      <aspsample:weatherwebpart id="zipConsumer" runat="server" 
        title="Zip Code Consumer" />
    </zonetemplate>
  </asp:webpartzone>
  </div>
  
  <div>
  <asp:button id="Button1" runat="server" 
    text="WebPartManager Information" onclick="Button1_Click" />
  <br />
  
  </div>
  
  <asp:connectionszone id="ConnectionsZone1" runat="server" />
  <asp:literal id="Literal1" runat="server" />

</asp:Content>

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).

Windows 98, Windows Server 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 Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

Community Additions

ADD
Show:
© 2014 Microsoft