Share via


ProxyWebPartManager.StaticConnections Propiedad

Definición

Obtiene una colección de conexiones estáticas declarada dentro del elemento <asp:proxywebpartmanager> de una página de contenido.

public:
 property System::Web::UI::WebControls::WebParts::ProxyWebPartConnectionCollection ^ StaticConnections { System::Web::UI::WebControls::WebParts::ProxyWebPartConnectionCollection ^ get(); };
[System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)]
public System.Web.UI.WebControls.WebParts.ProxyWebPartConnectionCollection StaticConnections { get; }
[<System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)>]
member this.StaticConnections : System.Web.UI.WebControls.WebParts.ProxyWebPartConnectionCollection
Public ReadOnly Property StaticConnections As ProxyWebPartConnectionCollection

Valor de propiedad

Una colección ProxyWebPartConnectionCollection que contiene todos los objetos WebPartConnection estáticos declarados en un elemento <asp:proxywebpartmanager>.

Atributos

Ejemplos

En el ejemplo de código siguiente se muestra cómo usar la StaticConnections propiedad en la ProxyWebPartManager clase . En este ejemplo de código solo se muestra la parte pertinente del código de la página de contenido que declara el ProxyWebPartManager control y la conexión estática. Para las demás páginas necesarias para ejecutar el ejemplo de código y una descripción de cómo configurarlas, consulte la sección Ejemplo de la información general de la ProxyWebPartManager clase.

El código siguiente es la página de contenido que declara el <staticconnections> elemento como elemento secundario del <asp:proxywebpartmanager> elemento. Tenga en cuenta también que el Button1_Click método comprueba el recuento de la StaticConnections propiedad en el ProxyWebPartManager control y lo escribe en la página.

<%@ 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>
<%@ Page Language="VB" MasterPageFile="~/MasterPageVB.master" 
  Title="Connections Page" %>
<%@ Register TagPrefix="aspSample" 
    Namespace="Samples.AspNet.VB.Controls" %>

<script runat="server">

  Protected Sub Button1_Click(ByVal sender As Object, _
    ByVal e As EventArgs)

    Dim lblText As StringBuilder = New StringBuilder()

    If Not (Page.Master.FindControl("WebPartManager1") Is Nothing) Then
      Dim theMgr As WebPartManager = _
        CType(Page.Master.FindControl("WebPartManager1"), WebPartManager)
      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 />")
    End If

    If Not (proxymgr1 Is Nothing) Then
      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 />")
    End If

    Literal1.Text = lblText.ToString()
    
  End Sub

</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 />
  <asp:literal id="Literal1" runat="server" />
  </div>
  
  <asp:connectionszone id="ConnectionsZone1" runat="server" />
  
</asp:Content>

Después de cargar la página en un explorador, haga clic en el botón Información de WebPartManager y observe la información sobre el WebPartManager control en la página maestra y el ProxyWebPartManager control de la página de contenido. Por ejemplo, tenga en cuenta que ambos tienen el mismo recuento en sus respectivas propiedades que realizan un seguimiento de las conexiones estáticas (la StaticConnections propiedad ).

Comentarios

La StaticConnections propiedad hace referencia a la colección de WebPartConnection objetos declarados en un <asp:proxywebpartmanager> elemento . Las conexiones contenidas en esta colección se agregan a las conexiones estáticas de los WebPartManager controles (a las que hace referencia su WebPartManager.StaticConnections colección) y se tratan exactamente como cualquier otra conexión asociada al WebPartManager control.

El elemento declarativo que corresponde a la StaticConnections propiedad es el <staticconnections> elemento . En una aplicación que usa páginas maestras, el <staticconnections> elemento se agrega como elemento secundario del <asp:proxywebpartmanager> elemento en una página de contenido y, a su vez, se agrega un <asp:webpartconnection> elemento como elemento secundario del <staticconnections> elemento. Se pueden agregar varios <asp:webpartconnection> elementos a un <staticconnections> elemento y varias páginas de contenido pueden declarar conexiones estáticas como parte de una aplicación de páginas maestras.

Se aplica a

Consulte también