ProxyWebPartManager.StaticConnections プロパティ

定義

コンテンツ ページの <asp:proxywebpartmanager> 要素で宣言されている静的接続のコレクションを取得します。

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

プロパティ値

<asp:proxywebpartmanager> 要素で宣言されているすべての静的な ProxyWebPartConnectionCollection オブジェクトを格納する WebPartConnection

属性

次のコード例では、 クラスで プロパティを StaticConnections 使用する方法を ProxyWebPartManager 示します。 このコード例では、コントロールと静的接続を宣言するコンテンツ ページのコードの ProxyWebPartManager 関連部分のみを示します。 コード例の実行に必要なその他のページと、その設定方法の説明については、クラスの概要の「例」セクションを ProxyWebPartManager 参照してください。

次のコードは、要素を 要素の <staticconnections><asp:proxywebpartmanager> として宣言するコンテンツ ページです。 また、 メソッドはButton1_Clickコントロールの プロパティの数をStaticConnectionsProxyWebPartManagerチェックし、ページに書き込みます。

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

ブラウザーでページを読み込んだ後、[ WebPartManager 情報 ] ボタンをクリックし、マスター ページのコントロールとコンテンツ ページのコントロールに関 WebPartManager する ProxyWebPartManager 情報を確認します。 たとえば、静的接続 (プロパティ) を追跡するそれぞれのプロパティで、両方とも同じ数を持つことに StaticConnections 注意してください。

注釈

プロパティは StaticConnections 、 要素で宣言されたオブジェクトの WebPartConnection コレクションを <asp:proxywebpartmanager> 参照します。 このコレクションに含まれる接続は、コントロールの WebPartManager 静的接続 (コレクション WebPartManager.StaticConnections によって参照) に追加され、コントロールに関連付 WebPartManager けられている他の接続とまったく同じように処理されます。

プロパティに対応する StaticConnections 宣言型要素は、 <staticconnections> 要素です。 マスター ページを使用するアプリケーションでは、 <staticconnections> 要素がコンテンツ ページの要素の <asp:proxywebpartmanager> 子として追加され <asp:webpartconnection> 、要素が要素の <staticconnections> 子として追加されます。 複数の <asp:webpartconnection> 要素を 1 つの <staticconnections> 要素に追加でき、複数のコンテンツ ページでマスター ページ アプリケーションの一部として静的接続を宣言できます。

適用対象

こちらもご覧ください