WebPartManager.StaticConnections プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > WebPartManager.StaticConnections プロパティの意味・解説 

WebPartManager.StaticConnections プロパティ

メモ : このプロパティは、.NET Framework version 2.0 で新しく追加されたものです。

Web ページ上の静的接続として定義されているすべての WebPartConnection オブジェクトのコレクションへの参照を取得します。

名前空間: System.Web.UI.WebControls.WebParts
アセンブリ: System.Web (system.web.dll 内)
構文構文

Public ReadOnly Property
 StaticConnections As WebPartConnectionCollection
Dim instance As WebPartManager
Dim value As WebPartConnectionCollection

value = instance.StaticConnections
public WebPartConnectionCollection StaticConnections { get;
 }
public:
property WebPartConnectionCollection^ StaticConnections {
    WebPartConnectionCollection^ get ();
}
/** @property */
public WebPartConnectionCollection get_StaticConnections ()
public function get StaticConnections
 () : WebPartConnectionCollection

プロパティ値
ページ上のすべての静的接続が格納された WebPartConnectionCollection。

解説解説
使用例使用例

StaticConnections プロパティのプログラムでの使用方法を示すコード例を次に示します。

コード例は、次の 4 つの部分から成ります。

次のコードには、コード例の Web ページ部分のみが含まれています。また、WebPartManager クラスの概要の「例」から、その例の最初の 2 つの部分、カスタム ユーザー コントロールおよびカスタム コントロールとインターフェイスのソース コードを取得する必要があります。そのトピックでは、WebPart コントロールをコンパイルするオプションについても説明しています。

コード例の 3 番目の部分は Web ページです。このページの宣言マークアップには、ユーザー コントロールとカスタム コントロール両方の Register ディレクティブが含まれています。<asp:webpartmanager> 要素、カスタム コントロールを格納する <asp:webpartzone> 要素、および <asp:connectionszone> 要素があります。Page_Load メソッドで、コードにより接続が既に存在しているかどうかがチェックされ、存在していない場合は、プロバイダ、コンシューマ、およびそのそれぞれのコネクション ポイントを定義し、新しい接続を StaticConnections プロパティで参照される静的接続のセットに追加します。

<%@ Page Language="vb" %>
<%@ register TagPrefix="uc1" 
  TagName="DisplayModeMenuVB" 
  Src="DisplayModeMenuVB.ascx" %>
<%@ register tagprefix="aspSample" 
  Namespace="Samples.AspNet.VB.Controls"
 
  Assembly="ConnectionSampleVB"%>

<script runat="server">

  Protected Sub Page_Load(ByVal
 sender As Object, _
    ByVal e As System.EventArgs)
    
    ' Define provider, consumer, and connection points.
    Dim provider As WebPart = mgr.WebParts("zip1")
    Dim provConnPoint As ProviderConnectionPoint
 = _
      mgr.GetProviderConnectionPoints(provider)("ZipCodeProvider")
    Dim consumer As WebPart = mgr.WebParts("weather1")
    Dim consConnPoint As ConsumerConnectionPoint
 = _
      mgr.GetConsumerConnectionPoints(consumer)("ZipCodeConsumer")
    
    ' Check whether the connection already exists.
    If mgr.CanConnectWebParts(provider, provConnPoint, _
      consumer, consConnPoint) Then
      ' Create a new static connection.
      Dim conn As New WebPartConnection()
      conn.ID = "staticConn1"
      conn.ConsumerID = "weather1"
      conn.ConsumerConnectionPointID = "ZipCodeConsumer"
      conn.ProviderID = "zip1"
      conn.ProviderConnectionPointID = "ZipCodeProvider"
      mgr.StaticConnections.Add(conn)
    End If
    
  End Sub
  
</script>

<html  >
<head id="Head1" runat="server">
</head>
<body>
    <form id="form1" runat="server">
      <!-- Reference the WebPartManager control. -->
      <asp:WebPartManager ID="mgr" runat="server"
 />   
    <div>
      <uc1:DisplayModeMenuVB ID="displaymode1"
 
        runat="server" />
      <!-- Reference consumer and provider controls 
           in a zone. -->
      <asp:WebPartZone ID="WebPartZone1" runat="server">
        <ZoneTemplate>
          <aspSample:ZipCodeWebPart ID="zip1" 
            runat="server" 
            Title="Zip Code Control"/>
          <aspSample:WeatherWebPart ID="weather1"
 
            runat="server" 
            Title="Weather Control" />
        </ZoneTemplate>
      </asp:WebPartZone>
      <hr />
      <!-- Add a ConnectionsZone so users can connect 
           controls. -->
      <asp:ConnectionsZone ID="ConnectionsZone1"
 
        runat="server" />
    </div>
    </form>
</body>
</html>
<%@ Page Language="C#" %>
<%@ register TagPrefix="uc1" 
  TagName="DisplayModeMenuCS" 
  Src="DisplayModeMenuCS.ascx" %>
<%@ register tagprefix="aspSample" 
  Namespace="Samples.AspNet.CS.Controls" 
  Assembly="ConnectionSampleCS"%>

<script runat="server">

  protected void Page_Load(object sender, EventArgs
 e)
  {
    
    // Define provider, consumer, and connection points.
    WebPart provider = mgr.WebParts["zip1"];
    ProviderConnectionPoint provConnPoint =
      mgr.GetProviderConnectionPoints(provider)["ZipCodeProvider"];
    WebPart consumer = mgr.WebParts["weather1"];
    ConsumerConnectionPoint consConnPoint =
      mgr.GetConsumerConnectionPoints(consumer)["ZipCodeConsumer"];
    
    // Check whether the connection already exists.
    if (mgr.CanConnectWebParts(provider, provConnPoint,
      consumer, consConnPoint))
    {
      // Create a new static connection.
      WebPartConnection conn = new WebPartConnection();
      conn.ID = "staticConn1";
      conn.ConsumerID = "weather1";
      conn.ConsumerConnectionPointID = "ZipCodeConsumer";
      conn.ProviderID = "zip1";
      conn.ProviderConnectionPointID = "ZipCodeProvider";
      mgr.StaticConnections.Add(conn);
    }
 }

</script>

<html  >
<head id="Head1" runat="server">
</head>
<body>
    <form id="form1" runat="server">
      <!-- Reference the WebPartManager control. -->
      <asp:WebPartManager ID="mgr" runat="server" />  
 
    <div>
      <uc1:DisplayModeMenuCS ID="displaymode1" 
        runat="server" />
      <!-- Reference consumer and provider controls 
           in a zone. -->
      <asp:WebPartZone ID="WebPartZone1" runat="server">
        <ZoneTemplate>
          <aspSample:ZipCodeWebPart ID="zip1" 
            runat="server" 
            Title="Zip Code Control"/>
          <aspSample:WeatherWebPart ID="weather1" 
            runat="server" 
            Title="Weather Control" />
        </ZoneTemplate>
      </asp:WebPartZone>
      <hr />
      <!-- Add a ConnectionsZone so users can connect 
           controls. -->
      <asp:ConnectionsZone ID="ConnectionsZone1" 
        runat="server" />
    </div>
    </form>
</body>
</html>

ブラウザに Web ページを読み込んだ後、[Display Mode] ドロップダウン リスト コントロールをクリックし、[接続] を選択してページを接続モードに切り替えます。接続モードは、<asp:connectionszone> 要素を使用して、コントロールの間に接続を作成できるようにします。接続モードで、[ZIP Code] コントロールのタイトル バーにある下向きの矢印をクリックしてその動詞メニューをアクティブにし、[接続] をクリックします。接続ユーザー インターフェイス (UI) が表示されたら、Page_Load メソッドに格納されているコードによって既に接続が作成されていることを確認します。後のブラウザ セッションでこのページに戻る場合、この静的接続は既に確立されているため、ページを読み込むたびに再作成する必要はありません。

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
WebPartManager クラス
WebPartManager メンバ
System.Web.UI.WebControls.WebParts 名前空間
WebPartConnection クラス
その他の技術情報
ASP.NET Web パーツ ページ



英和和英テキスト翻訳

英語⇒日本語日本語⇒英語

辞書ショートカット

すべての辞書の索引

「WebPartManager.StaticConnections プロパティ」の関連用語

WebPartManager.StaticConnections プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



WebPartManager.StaticConnections プロパティのページの著作権

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2026 Microsoft.All rights reserved.

©2026 GRAS Group, Inc.RSS