ConnectionsZone コンストラクター

定義

ConnectionsZone クラスの新しいインスタンスを初期化します。

public:
 ConnectionsZone();
public ConnectionsZone ();
Public Sub New ()

次のコード例は、コンストラクターを ConnectionsZone 使用して、プログラムによって Web ページに追加するコントロールの ConnectionsZone 新しいインスタンスを作成する方法を示しています。 この例には、コンストラクターの使用を示す Web ページのコードのみが含まれています。この例を実行するために必要な他の 2 つのコード ファイルについては、クラスの概要の「例」セクションを ConnectionsZone 参照してください。 コード例には、次の 4 つの部分があります。

  • Web ページの表示モードを切り替えるユーザー コントロール。 クラスの概要からこのコードを ConnectionsZone 取得します。

  • ZIP コード インターフェイスのコードと、接続のプロバイダーとコンシューマーとして機能する 2 つの WebPart コントロールを含むソース ファイル。 クラスの概要からこのコードを ConnectionsZone 取得します。

  • すべてのコントロールをホストし、その Page_Init メソッドでコンストラクターを ConnectionsZone 使用してコントロールの ConnectionsZone 新しいインスタンスを作成し、それをページに追加する Web ページ。

  • ブラウザーでの例の動作の説明。

Web ページのメソッドで Page_Init 、新 ConnectionsZone しいコントロールが (コンストラクターを使用して) 作成され、ページに追加されます。 ユーザーがページを接続モードに設定し、いずれかのコントロールで接続動詞を WebPart クリックすると、 ConnectionsZone コントロールが表示されます。

<%@ Page Language="C#" %>
<%@ register tagprefix="uc1" 
    tagname="DisplayModeMenuCS"
    src="~/displaymodemenucs.ascx" %>
<%@ Register TagPrefix="aspSample" 
    Namespace="Samples.AspNet.CS.Controls" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
  protected void Page_Init(object sender, EventArgs e)
  {
    ConnectionsZone connZone = new ConnectionsZone();
    connZone.ID = "connectionsZone1";
    connZone.HeaderText = "Connections Zone 1";
    form1.Controls.AddAt(form1.Controls.Count - 1, connZone);
  }
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Connection Zone Sample</title>
</head>
<body>
  <form id="form1" runat="server">
  <asp:webpartmanager runat="server" id="mgr">
    <staticconnections>
      <asp:webpartconnection id="connection1" 
        consumerconnectionpointid="ZipCodeConsumer"
        consumerid="zipConsumer"
        providerconnectionpointid="ZipCodeProvider" 
        providerid="zipProvider" />
    </staticconnections>
  </asp:webpartmanager>
  <uc1:displaymodemenucs id="menu1" runat="server" />
  <div>
  <asp:webpartzone id="WebPartZone1" 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>
  </form>
</body>
</html>
<%@ Page Language="VB" %>
<%@ register tagprefix="uc1" 
    tagname="DisplayModeMenuVB"
    src="~/displaymodemenuvb.ascx" %>
<%@ Register TagPrefix="aspSample" 
    Namespace="Samples.AspNet.VB.Controls" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

  Protected Sub Page_Init(ByVal sender As Object, _
    ByVal e As System.EventArgs)
    
    Dim connZone As ConnectionsZone = New ConnectionsZone()
    connZone.ID = "connectionsZone1"
    connZone.HeaderText = "Connections Zone 1"
    form1.Controls.AddAt(form1.Controls.Count - 1, connZone)

  End Sub
  
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Connection Zone Sample</title>
</head>
<body>
  <form id="form1" runat="server">
  <asp:webpartmanager runat="server" id="mgr">
    <staticconnections>
      <asp:webpartconnection id="connection1" 
        consumerconnectionpointid="ZipCodeConsumer"
        consumerid="zipConsumer"
        providerconnectionpointid="ZipCodeProvider" 
        providerid="zipProvider" />
    </staticconnections>
  </asp:webpartmanager>
  <uc1:displaymodemenuvb id="menu1" runat="server" />
  <div>
  <asp:webpartzone id="WebPartZone1" 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>
  </form>
</body>
</html>

ブラウザーでページを読み込みます。 ディスプレイ モード コントロールを使用して、接続 モード に切り替えます。 郵便番号プロバイダー コントロールの動詞メニュー矢印をクリックし、接続動詞をクリックします。 接続 UI が表示され、ページのマークアップで接続が宣言されたため、コントロールは既に接続されています。

注釈

このパラメーターなしのコンストラクターは、ASP.NET ページで要素を<asp:connectionszone>宣言するときに呼び出されます。 プログラムによってページにコントロールを追加する場合を除き、このコンストラクターを暗黙的に呼び出す必要はありません。

適用対象

こちらもご覧ください