Share via


ProxyWebPartManager.StaticConnections Proprietà

Definizione

Ottiene un insieme di connessioni statiche dichiarate nell'elemento <asp:proxywebpartmanager> in una pagina di contenuto.

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

Valore della proprietà

Insieme ProxyWebPartConnectionCollection contenente tutti gli oggetti WebPartConnection statici dichiarati in un elemento <asp:proxywebpartmanager>.

Attributi

Esempio

Nell'esempio di codice seguente viene illustrato come usare la StaticConnections proprietà nella ProxyWebPartManager classe . Questo esempio di codice mostra solo la parte pertinente del codice dalla pagina del contenuto che dichiara il ProxyWebPartManager controllo e la connessione statica. Per le altre pagine necessarie per eseguire l'esempio di codice e una descrizione di come configurarli, vedere la sezione Esempio della panoramica della ProxyWebPartManager classe.

Il codice seguente è la pagina del contenuto che dichiara l'elemento come elemento figlio dell'elemento <staticconnections><asp:proxywebpartmanager> . Si noti anche che il Button1_Click metodo controlla il conteggio della StaticConnections proprietà nel ProxyWebPartManager controllo e lo scrive nella pagina.

<%@ 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>

Dopo aver caricato la pagina in un browser, fare clic sul pulsante Informazioni WebPartManager e osservare le informazioni sul WebPartManager controllo nella pagina master e sul ProxyWebPartManager controllo nella pagina del contenuto. Si noti, ad esempio, che entrambi hanno lo stesso conteggio nelle rispettive proprietà che tengono traccia delle connessioni statiche (la StaticConnections proprietà).

Commenti

La StaticConnections proprietà fa riferimento all'insieme di WebPartConnection oggetti dichiarati in un <asp:proxywebpartmanager> elemento. Le connessioni contenute in questa raccolta vengono aggiunte alle connessioni statiche dei WebPartManager controlli (a cui fa riferimento la raccolta WebPartManager.StaticConnections ) e vengono trattate esattamente come qualsiasi altra connessione associata al WebPartManager controllo.

L'elemento dichiarativo che corrisponde alla proprietà è l'elemento StaticConnections<staticconnections> . In un'applicazione che usa pagine master, l'elemento <staticconnections> viene aggiunto come elemento figlio dell'elemento <asp:proxywebpartmanager> in una pagina del contenuto e un <asp:webpartconnection> elemento a sua volta viene aggiunto come elemento figlio dell'elemento <staticconnections> . È possibile aggiungere più <asp:webpartconnection> elementi a un <staticconnections> elemento e più pagine di contenuto possono dichiarare connessioni statiche come parte di un'applicazione di pagine master.

Si applica a

Vedi anche