ConnectionPointとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework用語 > ConnectionPointの意味・解説 

コネクション ポイント [connection point]

Web パーツ接続参加するプロバイダ コントロールおよびコンシューマ コントロール関連付けられている System.Web.UI.WebControls.WebParts.ConnectionPoint オブジェクト。コネクション ポイントは、コントロール間でのデータ交換管理しますプロバイダおよびコンシューマは、それぞれ独自のコネクション ポイントを持ちます。参照 : コンシューマプロバイダWeb パーツの接続

ConnectionPoint クラス

メモ : このクラスは、.NET Framework version 2.0新しく追加されたものです。

Web パーツ接続で、コンシューマ コントロールプロバイダ コントロールデータ共有できるようにするコネクション ポイント オブジェクト定義するための基本クラスとして機能します

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

Public MustInherit Class
 ConnectionPoint
Dim instance As ConnectionPoint
public abstract class ConnectionPoint
public ref class ConnectionPoint abstract
public abstract class ConnectionPoint
public abstract class ConnectionPoint
解説解説

すべての Web パーツ接続は、データ共有する 2 つサーバー コントロール構成されています。そのうち 1 つコンシューマで、もう 1 つプロバイダです。Web パーツ接続不可欠な構成要素接続オブジェクト自体詳細については、WebPartConnection クラス概要参照してくださいすべての Web パーツ接続には、コネクション ポイントが必要です。プロバイダ コントロールコンシューマ コントロールそれぞれ少なくとも 1 つ定義されConnectionPoint オブジェクト持っている必要があります (これらのコントロールはいずれも、オプションとして複数コネクション ポイントを持つこともできます)。このオブジェクトには、コントロールがもう一方コントロール接続する方法と、コントロール間で共有できるデータの型についての詳細格納されます。実際接続では、プロバイダが ProviderConnectionPoint のインスタンスである独自の型のコネクション ポイント オブジェクト (ConnectionPoint 基本クラスから派生) を持ちコンシューマも ConsumerConnectionPoint のインスタンスである独自のオブジェクト持ちます

プロバイダ コネクション ポイント作成するには、実装されたインターフェイス インスタンスコンシューマ返すコールバック メソッドプロバイダ追加する必要がありますソース コード内では、このコールバック メソッドConnectionProvider コード属性 (ConnectionProviderAttribute クラストピック参照) でマークする必要があります同様にコンシューマ接続ポイント作成するには、インターフェイス インスタンス受け取メソッドコンシューマ追加し、そのメソッドConnectionConsumer 属性 (ConnectionConsumerAttribute クラストピック参照) でマークする必要があります

開発者Web ページ上で接続作成するときは、静的接続または動的接続として作成できます静的接続は、Web ページマークアップ宣言されます。静的接続宣言されると、開発者は、<asp:webpartconnection> 要素タグ内の ProviderConnectionPointID 属性ConsumerConnectionPointID 属性に値を割り当てることにより、コンシューマプロバイダ両方使用するコネクション ポイント指定できます。このアプローチは、静的接続接続使用するコネクション ポイント識別できるため、コンシューマ コントロールプロバイダ コントロール複数コネクション ポイント定義されている場合に特に便利です。

動的接続プログラムによって作成されます。開発者コードによって作成するか、または、ユーザーが ConnectionsZone コントロールによって提供されるユーザー インターフェイス (UI) を通じて作成できます開発者コード接続作成するには、WebPartManager コントロールで ConnectWebParts メソッド呼び出しWebPartConnection オブジェクトインスタンス取得する必要があります。このメソッド呼び出すには、コンシューマ サーバー コントロールおよびプロバイダ サーバー コントロールへの参照と、それぞれのコネクション ポイント オブジェクトが必要です。プロバイダ コントロールコンシューマ コントロールコネクション ポイントへの参照取得するには、最初にWebPartManager コントロールで GetProviderConnectionPoints メソッドと GetConsumerConnectionPoints メソッド呼び出す必要があります。これらのメソッド該当するコネクション ポイント オブジェクト返します。このコネクション ポイント オブジェクトを、接続作成するためのメソッド渡します

プロバイダコネクション ポイント オブジェクトコンシューマコネクション ポイント オブジェクト両方が同じインターフェイス型対応している場合は、プロバイダコンシューマの間に互換性があり、両者直接接続構成してデータ共有できます。同じインターフェイス型対応してない場合は、WebPartTransformer オブジェクト使用してプロバイダインターフェイス インスタンスコンシューマ対応している型のインターフェイス インスタンス変換する必要があります

ConnectionPoint 抽象クラスは、コンシューマ コントロールプロバイダ コントロールの間で共有されるコネクション ポイント基本的な詳細提供します。これらの詳細格納するプロパティは、いくつかあります。AllowsMultipleConnections プロパティは、コネクション ポイント一度複数接続参加できるかどうか示します既定では、プロバイダ コネクション ポイント複数接続参加できますが、コンシューマ接続ポイント複数接続参加できません。ControlType プロパティは、コネクション ポイント関連付けられているサーバー コントロール種類示しますWebPart コントロールだけが接続構成できるのではなく、WebPartZoneBase ゾーン配置されている任意のサーバー コントロール (ASP.NET コントロールカスタム コントロール、またはユーザー コントロール) が接続参加できますDisplayName プロパティは、接続作成するユーザー支援する UI表示できるコネクション ポイント表示名提供しますID プロパティは、コネクション ポイント オブジェクト自体文字列識別子として機能しますInterfaceType プロパティは、コネクション ポイント理解できるインターフェイス型示します指定したコネクション ポイントがそのインターフェイスインスタンス提供する使用するかは、それが ProviderConnectionPoint オブジェクトであるか ConsumerConnectionPoint オブジェクトであるかによって決まります

ConnectionPoint クラスにはメソッド1 つあります。GetEnabled メソッドは、コネクション ポイントが現在接続参加できるかどうかを示すブール値を返します

ConnectionPoint クラスには、DefaultID というパブリック フィールド1 つあります。このフィールドは、接続既定コネクション ポイント識別するために使用される値を格納します

メモメモ

コネクション ポイントメソッド指定する属の必須パラメータは、displayName だけです。したがってID指定せずに既定コネクション ポイント属性作成できますそのような場合は、DefaultID フィールドが、使用する基本値を提供します

使用例使用例

必須の ConnectionPoint オブジェクトを含む Web パーツ接続作成するコード例次に示しますConnectionPoint クラス抽象基本クラスでなので、その子クラスインスタンス (ProviderConnectionPoint および ConsumerConnectionPoint) は、接続構成するために使用される実際オブジェクトとなります

この例は、4 つ部分構成されます。

コード例最初部分は、Web ページ上の表示モードユーザー変更できるようにするユーザー コントロールです。次のソース コード.ascx ファイル保存します。このファイルの名前は、ホストする Web ページ先頭近くにある、このユーザー コントロール用の Register ディレクティブSrc 属性割り当てられます。表示モード詳細、およびこのコントロールソース コード説明については、「チュートリアル : Web パーツ ページでの表示モード変更」を参照してください

<%@ control language="vb" classname="DisplayModeMenuVB"%>
<script runat="server">
  ' Use a field to reference the current WebPartManager.
  Dim _manager As WebPartManager

  Sub Page_Init(ByVal sender As
 Object, ByVal e As EventArgs)
    AddHandler Page.InitComplete, AddressOf
 InitComplete
  End Sub

  Sub InitComplete(ByVal sender As
 Object, ByVal e As System.EventArgs)
    _manager = WebPartManager.GetCurrentWebPartManager(Page)
      
    Dim browseModeName As String
 = WebPartManager.BrowseDisplayMode.Name
      
    ' Fill the dropdown with the names of supported display modes.
    Dim mode As WebPartDisplayMode
    For Each mode In _manager.SupportedDisplayModes
      Dim modeName As String
 = mode.Name
      ' Make sure a mode is enabled before adding it.
      If mode.IsEnabled(_manager) Then
        Dim item As New
 ListItem(modeName, modeName)
        DisplayModeDropdown.Items.Add(item)
      End If
    Next mode
      
    ' If shared scope is allowed for this user, display the scope-switching
    ' UI and select the appropriate radio button for the current user
 scope.
    If _manager.Personalization.CanEnterSharedScope Then
      Panel2.Visible = True
      If _manager.Personalization.Scope = PersonalizationScope.User
 Then
        RadioButton1.Checked = True
      Else
        RadioButton2.Checked = True
      End If
    End If
   
  End Sub

  ' Change the page to the selected display mode.
  Sub DisplayModeDropdown_SelectedIndexChanged(ByVal
 sender As Object, _
    ByVal e As EventArgs)
    
    Dim selectedMode As String
 = DisplayModeDropdown.SelectedValue   
    Dim mode As WebPartDisplayMode = _
      _manager.SupportedDisplayModes(selectedMode)
    If Not (mode Is Nothing)
 Then
      _manager.DisplayMode = mode
    End If

  End Sub
   
  ' Set the selected item equal to the current display mode.
  Sub Page_PreRender(ByVal sender As
 Object, ByVal e As EventArgs)
    Dim items As ListItemCollection = DisplayModeDropdown.Items
    Dim selectedIndex As Integer
 = _
      items.IndexOf(items.FindByText(_manager.DisplayMode.Name))
    DisplayModeDropdown.SelectedIndex = selectedIndex

  End Sub

  ' Reset all of a user's personalization data for the page.
  Protected Sub LinkButton1_Click(ByVal
 sender As Object, _
    ByVal e As EventArgs)
    
    _manager.Personalization.ResetPersonalizationState()
    
  End Sub

  ' If not in User personalization scope, toggle into it.
  Protected Sub RadioButton1_CheckedChanged(ByVal
 sender As Object, _
    ByVal e As EventArgs)
    
    If _manager.Personalization.Scope = PersonalizationScope.Shared
 Then
      _manager.Personalization.ToggleScope()
    End If

  End Sub
   
  ' If not in Shared scope, and if user is allowed, toggle the scope.
  Protected Sub RadioButton2_CheckedChanged(ByVal
 sender As Object, _
    ByVal e As EventArgs)
    
    If _manager.Personalization.CanEnterSharedScope AndAlso
 _
      _manager.Personalization.Scope = PersonalizationScope.User Then
      _manager.Personalization.ToggleScope()
    End If

  End Sub

</script>
<div>
  <asp:Panel ID="Panel1" runat="server"
 
    Borderwidth="1" 
    Width="230" 
    BackColor="lightgray"
    Font-Names="Verdana, Arial, Sans Serif" >
    <asp:Label ID="Label1" runat="server"
 
      Text="&nbsp;Display Mode" 
      Font-Bold="true"
      Font-Size="8"
      Width="120" />
    <asp:DropDownList ID="DisplayModeDropdown"
 runat="server"  
      AutoPostBack="true" 
      Width="120"
      OnSelectedIndexChanged="DisplayModeDropdown_SelectedIndexChanged"
 />
    <asp:LinkButton ID="LinkButton1" runat="server"
      Text="Reset User State" 
      ToolTip="Reset the current user's personalization data for
 the page."
      Font-Size="8" 
      OnClick="LinkButton1_Click" />
    <asp:Panel ID="Panel2" runat="server"
 
      GroupingText="Personalization Scope"
      Font-Bold="true"
      Font-Size="8" 
      Visible="false" >
      <asp:RadioButton ID="RadioButton1" runat="server"
 
        Text="User" 
        AutoPostBack="true"
        GroupName="Scope" OnCheckedChanged="RadioButton1_CheckedChanged"
 />
      <asp:RadioButton ID="RadioButton2" runat="server"
 
        Text="Shared" 
        AutoPostBack="true"
        GroupName="Scope" 
        OnCheckedChanged="RadioButton2_CheckedChanged"
 />
    </asp:Panel>
  </asp:Panel>
</div>
<%@ control language="C#" classname="DisplayModeMenuCS"%>
<script runat="server">
  
 // Use a field to reference the current WebPartManager.
  WebPartManager _manager;

  void Page_Init(object sender, EventArgs e)
  {
    Page.InitComplete += new EventHandler(InitComplete);
  }  

  void InitComplete(object sender, System.EventArgs e)
  {
    _manager = WebPartManager.GetCurrentWebPartManager(Page);

    String browseModeName = WebPartManager.BrowseDisplayMode.Name;

    // Fill the dropdown with the names of supported display modes.
    foreach (WebPartDisplayMode mode in _manager.SupportedDisplayModes)
    {
      String modeName = mode.Name;
      // Make sure a mode is enabled before adding it.
      if (mode.IsEnabled(_manager))
      {
        ListItem item = new ListItem(modeName, modeName);
        DisplayModeDropdown.Items.Add(item);
      }
    }

    // If shared scope is allowed for this user, display the scope-switching
    // UI and select the appropriate radio button for the current user
 scope.
    if (_manager.Personalization.CanEnterSharedScope)
    {
      Panel2.Visible = true;
      if (_manager.Personalization.Scope == PersonalizationScope.User)
        RadioButton1.Checked = true;
      else
        RadioButton2.Checked = true;
    }
    
  }
 
  // Change the page to the selected display mode.
  void DisplayModeDropdown_SelectedIndexChanged(object sender,
 EventArgs e)
  {
    String selectedMode = DisplayModeDropdown.SelectedValue;

    WebPartDisplayMode mode = _manager.SupportedDisplayModes[selectedMode];
    if (mode != null)
      _manager.DisplayMode = mode;
  }

  // Set the selected item equal to the current display mode.
  void Page_PreRender(object sender, EventArgs e)
  {
    ListItemCollection items = DisplayModeDropdown.Items;
    int selectedIndex = 
      items.IndexOf(items.FindByText(_manager.DisplayMode.Name));
    DisplayModeDropdown.SelectedIndex = selectedIndex;
  }

  // Reset all of a user's personalization data for the page.
  protected void LinkButton1_Click(object sender,
 EventArgs e)
  {
    _manager.Personalization.ResetPersonalizationState();
  }

  // If not in User personalization scope, toggle into it.
  protected void RadioButton1_CheckedChanged(object
 sender, EventArgs e)
  {
    if (_manager.Personalization.Scope == PersonalizationScope.Shared)
      _manager.Personalization.ToggleScope();
  }

  // If not in Shared scope, and if user is allowed, toggle the scope.
  protected void RadioButton2_CheckedChanged(object
 sender, EventArgs e)
  {
    if (_manager.Personalization.CanEnterSharedScope &&
 
        _manager.Personalization.Scope == PersonalizationScope.User)
      _manager.Personalization.ToggleScope();
  }
</script>
<div>
  <asp:Panel ID="Panel1" runat="server" 
    Borderwidth="1" 
    Width="230" 
    BackColor="lightgray"
    Font-Names="Verdana, Arial, Sans Serif" >
    <asp:Label ID="Label1" runat="server" 
      Text="&nbsp;Display Mode" 
      Font-Bold="true"
      Font-Size="8"
      Width="120" />
    <asp:DropDownList ID="DisplayModeDropdown" runat="server"
  
      AutoPostBack="true" 
      Width="120"
      OnSelectedIndexChanged="DisplayModeDropdown_SelectedIndexChanged"
 />
    <asp:LinkButton ID="LinkButton1" runat="server"
      Text="Reset User State" 
      ToolTip="Reset the current user's personalization data for
 the page."
      Font-Size="8" 
      OnClick="LinkButton1_Click" />
    <asp:Panel ID="Panel2" runat="server" 
      GroupingText="Personalization Scope"
      Font-Bold="true"
      Font-Size="8" 
      Visible="false" >
      <asp:RadioButton ID="RadioButton1" runat="server" 
        Text="User" 
        AutoPostBack="true"
        GroupName="Scope" OnCheckedChanged="RadioButton1_CheckedChanged"
 />
      <asp:RadioButton ID="RadioButton2" runat="server" 
        Text="Shared" 
        AutoPostBack="true"
        GroupName="Scope" 
        OnCheckedChanged="RadioButton2_CheckedChanged" />
    </asp:Panel>
  </asp:Panel>
</div>

コード例2 番目の部分は、インターフェイスコントロールソース コードです。ソース ファイルには、IZipCode という名前の単純なインターフェイス含まれています。また、インターフェイス実装してプロバイダ コントロールとして動作するZipCodeWebPart という名前の WebPart クラス存在します。その ProvideIZipCode メソッドは、インターフェイス唯一のメンバ実装されたコールバック メソッドです。このメソッドは、単にインターフェイスインスタンス返すだけです。このメソッドメタデータConnectionProvider 属性マークされます。これは、メソッドプロバイダコネクション ポイントコールバック メソッドとして識別するしくみです。もう 1 つWebPart クラスWeatherWebPart という名前で、接続コンシューマとして動作します。このクラスは、プロバイダ コントロールかIZipCode インターフェイスインスタンス取得するGetZipCode という名前のメソッド持ってます。このメソッドは、コンシューマコネクション ポイント メソッドとして、メタデータConnectionConsumer 属性マークされます。これは、コンシューマ コントロールコネクション ポイント メソッド識別するためのしくみです。

コード例実行するためには、このソース コードコンパイルする必要があります。それを明示的にコンパイルし、コンパイル済みアセンブリWeb サイトBin フォルダまたはグローバル アセンブリ キャッシュ配置できますサイトの App_Code フォルダソース コード配置し実行時動的にコンパイルすることもできます。このコード例は、動的コンパイル使用しますコンパイル方法を示すチュートリアルについては、「チュートリアル : カスタム サーバー コントロール開発と使用」を参照してください

Imports System
Imports System.Web
Imports System.Web.Security
Imports System.Security.Permissions
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts

Namespace Samples.AspNet.VB.Controls

  <AspNetHostingPermission(SecurityAction.Demand, _
    Level:=AspNetHostingPermissionLevel.Minimal)> _
  <AspNetHostingPermission(SecurityAction.InheritanceDemand, _
    Level:=AspNetHostingPermissionLevel.Minimal)> _
  Public Interface IZipCode

    Property ZipCode() As String

  End Interface

  <AspNetHostingPermission(SecurityAction.Demand, _
    Level:=AspNetHostingPermissionLevel.Minimal)> _
  <AspNetHostingPermission(SecurityAction.InheritanceDemand, _
    Level:=AspNetHostingPermissionLevel.Minimal)> _
  Public Class ZipCodeWebPart
    Inherits WebPart
    Implements IZipCode
    Private zipCodeText As String
 = String.Empty
    Private input As TextBox
    Private send As Button

    Public Sub New()
    End Sub

    ' Make the implemented property personalizable to save 
    ' the Zip Code between browser sessions.
    <Personalizable()> _
    Public Property ZipCode() As
 String _
      Implements IZipCode.ZipCode

      Get
        Return zipCodeText
      End Get
      Set(ByVal value As
 String)
        zipCodeText = value
      End Set
    End Property

    ' This is the callback method that returns the provider.
    <ConnectionProvider("Zip Code Provider", "ZipCodeProvider")>
 _
    Public Function ProvideIZipCode() As
 IZipCode
      Return Me
    End Function


    Protected Overrides Sub
 CreateChildControls()
      Controls.Clear()
      input = New TextBox()
      Me.Controls.Add(input)
      send = New Button()
      send.Text = "Enter 5-digit Zip Code"
      AddHandler send.Click, AddressOf Me.submit_Click
      Me.Controls.Add(send)

    End Sub


    Private Sub submit_Click(ByVal
 sender As Object, _
      ByVal e As EventArgs)

      If input.Text <> String.Empty Then
        zipCodeText = Page.Server.HtmlEncode(input.Text)
        input.Text = String.Empty
      End If

    End Sub

  End Class

  <AspNetHostingPermission(SecurityAction.Demand, _
    Level:=AspNetHostingPermissionLevel.Minimal)> _
  <AspNetHostingPermission(SecurityAction.InheritanceDemand, _
    Level:=AspNetHostingPermissionLevel.Minimal)> _
  Public Class WeatherWebPart
    Inherits WebPart
    Private _provider As IZipCode
    Private _zipSearch As String
    Private DisplayContent As Label

    ' This method is identified by the ConnectionConsumer 
    ' attribute, and is the mechanism for connecting with 
    ' the provider. 
    <ConnectionConsumer("Zip Code Consumer", "ZipCodeConsumer")>
 _
    Public Sub GetIZipCode(ByVal
 Provider As IZipCode)
      _provider = Provider
    End Sub


    Protected Overrides Sub
 OnPreRender(ByVal e As EventArgs)
      EnsureChildControls()

      If Not (Me._provider
 Is Nothing) Then
        _zipSearch = _provider.ZipCode.Trim()
                DisplayContent.Text = "My Zip Code is:  "
 + _zipSearch
      End If

    End Sub 'OnPreRender

    Protected Overrides Sub
 CreateChildControls()
      Controls.Clear()
      DisplayContent = New Label()
      Me.Controls.Add(DisplayContent)

    End Sub

  End Class

End Namespace
namespace Samples.AspNet.CS.Controls
{
  using System;
  using System.Web;
  using System.Web.Security;
  using System.Security.Permissions;
  using System.Web.UI;
  using System.Web.UI.WebControls;
  using System.Web.UI.WebControls.WebParts;

  [AspNetHostingPermission(SecurityAction.Demand,
    Level = AspNetHostingPermissionLevel.Minimal)]
  [AspNetHostingPermission(SecurityAction.InheritanceDemand,
    Level = AspNetHostingPermissionLevel.Minimal)]
  public interface IZipCode
  {
    string ZipCode { get; set;}
  }

  [AspNetHostingPermission(SecurityAction.Demand,
    Level = AspNetHostingPermissionLevel.Minimal)]
  [AspNetHostingPermission(SecurityAction.InheritanceDemand,
    Level = AspNetHostingPermissionLevel.Minimal)]
  public class ZipCodeWebPart : WebPart, IZipCode
  {
    string zipCodeText = String.Empty;
    TextBox input;
    Button send;

    public ZipCodeWebPart()
    {
    }

    // Make the implemented property personalizable to save 
    // the Zip Code between browser sessions.
    [Personalizable()]
    public virtual string ZipCode
    {
      get { return zipCodeText; }
      set { zipCodeText = value; }
    }

    // This is the callback method that returns the provider.
    [ConnectionProvider("Zip Code Provider", "ZipCodeProvider")]
    public IZipCode ProvideIZipCode()
    {
      return this;
    }

    protected override void CreateChildControls()
    {
      Controls.Clear();
      input = new TextBox();
      this.Controls.Add(input);
      send = new Button();
      send.Text = "Enter 5-digit Zip Code";
      send.Click += new EventHandler(this.submit_Click);
      this.Controls.Add(send);
    }

    private void submit_Click(object sender,
 EventArgs e)
    {
      if (input.Text != String.Empty)
      {
        zipCodeText = Page.Server.HtmlEncode(input.Text);
        input.Text = String.Empty;
      }
    }

  }

  [AspNetHostingPermission(SecurityAction.Demand,
    Level = AspNetHostingPermissionLevel.Minimal)]
  [AspNetHostingPermission(SecurityAction.InheritanceDemand,
    Level = AspNetHostingPermissionLevel.Minimal)]
  public class WeatherWebPart : WebPart
  {
    private IZipCode _provider;
    string _zipSearch;
    Label DisplayContent;

    // This method is identified by the ConnectionConsumer 
    // attribute, and is the mechanism for connecting with 
    // the provider. 
    [ConnectionConsumer("Zip Code Consumer", "ZipCodeConsumer")]
    public void GetIZipCode(IZipCode Provider)
    {
      _provider = Provider;
    }
    
    protected override void OnPreRender(EventArgs
 e)
    {
      EnsureChildControls();

      if (this._provider != null)
      {
        _zipSearch = _provider.ZipCode.Trim();
        DisplayContent.Text = "My Zip Code is:  " + _zipSearch;
      }
    }

    protected override void CreateChildControls()
    {
      Controls.Clear();
      DisplayContent = new Label();
      this.Controls.Add(DisplayContent);
    }

  }
}

コード例3 番目の部分Web ページです。先頭近くには、接続構成するカスタム コントロール登録する Register ディレクティブ、およびユーザーページ表示モード変更できるユーザー コントロールあります接続は、ページ<staticconnections> 要素内での宣言によって作成されます。また、プログラムによって接続作成することもできます。そのためのコードは、Button1_Click メソッドあります接続宣言作成するか、プログラム作成するかにかかわらずコネクション ポイントプロバイダコンシューマ両方に対して指定する必要がありますButton2_Click メソッドプロバイダコンシューマ両方ConnectionPoint オブジェクトアクセスし、そのプロパティ値の一部ページラベル書き込みます

<%@ 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 Button1_Click(ByVal
 sender As Object, _
    ByVal e As System.EventArgs)

    Dim provPoint As ProviderConnectionPoint
 = _
      mgr.GetProviderConnectionPoints(zip1)("ZipCodeProvider")
    Dim connPoint As ConsumerConnectionPoint
 = _
      mgr.GetConsumerConnectionPoints(weather1)("ZipCodeConsumer")

    If mgr.CanConnectWebParts(zip1, provPoint, weather1, connPoint)
 Then
      mgr.ConnectWebParts(zip1, provPoint, weather1, connPoint)
    End If
    
  End Sub
  
  Protected Sub Button2_Click(ByVal
 sender As Object, _
    ByVal e As System.EventArgs)
    
    Dim conn As WebPartConnection = mgr.Connections(0)

    lblConn.Text = "<h2>Connection Point Details</h2>"
 & _
      "<h3>Provider Connection Point</h3>"
 & _
      "  Display name: " & conn.ProviderConnectionPoint.DisplayName
 & _
      "<br />" & _
      "  ID: " & conn.ProviderConnectionPoint.ID
 & _
      "<br />" & _
      "  Interface type: " & conn.ProviderConnectionPoint.InterfaceType.ToString()
 & _
      "<br />" & _
      "  Control type: " & conn.ProviderConnectionPoint.ControlType.ToString()
 & _
      "<br />" & _
      "  Allows multiple connections: " & _
        conn.ProviderConnectionPoint.AllowsMultipleConnections.ToString() & _
      "<br />" & _
      "  Enabled: " & conn.ProviderConnectionPoint.GetEnabled(zip1).ToString()
 & _
      "<hr />" & _
      "<h3>Consumer Connection Point</h3>"
 & _
      "  Display name: " & conn.ConsumerConnectionPoint.DisplayName
 & _
      "<br />" & _
      "  ID: " & conn.ConsumerConnectionPoint.ID
 & _
      "<br />" & _
      "  Interface type: " & conn.ConsumerConnectionPoint.InterfaceType.ToString()
 & _
      "<br />" & _
      "  Control type: " & conn.ConsumerConnectionPoint.ControlType.ToString()
 & _
      "<br />" & _
      "  Allows multiple connections: " & _
        conn.ConsumerConnectionPoint.AllowsMultipleConnections.ToString() & _
      "<br />" & _
      "  Enabled: " & conn.ConsumerConnectionPoint.GetEnabled(zip1).ToString()
          
  End Sub

  Protected Sub Page_Load(ByVal
 sender As Object, _
    ByVal e As System.EventArgs)
    lblConn.Text = String.Empty
  End Sub
  
</script>

<html  >
<head id="Head1" runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
      <asp:WebPartManager ID="mgr" runat="server"
 >
        <StaticConnections>
          <asp:WebPartConnection ID="conn1"
            ConsumerConnectionPointID="ZipCodeConsumer"
            ConsumerID="weather1" 
            ProviderConnectionPointID="ZipCodeProvider"
 
            ProviderID="zip1" />
        </StaticConnections>      
      </asp:WebPartManager>
      <uc1:displaymodemenuvb id="menu1" runat="server"
 />
      <asp:WebPartZone ID="WebPartZone1" runat="server">
        <ZoneTemplate>
          <aspSample:ZipCodeWebPart ID="zip1" runat="server"
            Title="Zip Code Provider"  />
          <aspSample:WeatherWebPart ID="weather1"
 runat="server" 
            Title="Zip Code Consumer" />
        </ZoneTemplate>
      </asp:WebPartZone>
      <asp:ConnectionsZone ID="ConnectionsZone1"
 runat="server">
      </asp:ConnectionsZone>
      <asp:Button ID="Button1" runat="server"
 
        Text="Dynamic Connection" 
        OnClick="Button1_Click" />      
      <br />
      <asp:Button ID="Button2" runat="server"
 
        Text="Connection Point Details" 
        OnClick="Button2_Click" />
      <br />
      <asp:Label ID="lblConn" 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" %>
    
<!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 Button1_Click(object sender,
 EventArgs e)
  {
    ProviderConnectionPoint provPoint =
      mgr.GetProviderConnectionPoints(zip1)["ZipCodeProvider"];
    ConsumerConnectionPoint connPoint =
      mgr.GetConsumerConnectionPoints(weather1)["ZipCodeConsumer"];
      
    if(mgr.CanConnectWebParts(zip1, provPoint, weather1, connPoint))
      mgr.ConnectWebParts(zip1, provPoint, weather1, connPoint);
  
  }  
  protected void Button2_Click(object sender,
 EventArgs e)
  {
    WebPartConnection conn = mgr.Connections[0];
    
    lblConn.Text = "<h2>Connection Point Details</h2>" + 
       "<h3>Provider Connection Point</h3>" + 
       "  Display name: " + conn.ProviderConnectionPoint.DisplayName +
 
       "<br />" + 
       "  ID: " + conn.ProviderConnectionPoint.ID + 
       "<br />" + 
       "  Interface type: " + 
        conn.ProviderConnectionPoint.InterfaceType.ToString() + 
       "<br />" + 
       "  Control type: " + conn.ProviderConnectionPoint.ControlType.ToString()
 + 
       "<br />" + 
       "  Allows multiple connections: " + 
          conn.ProviderConnectionPoint.AllowsMultipleConnections.ToString() + 
       "<br />" + 
       "  Enabled: " + conn.ProviderConnectionPoint.GetEnabled(zip1).ToString()
 + 
       "<hr />" + 
       "<h3>Consumer Connection Point</h3>" + 
       "  Display name: " + conn.ConsumerConnectionPoint.DisplayName +
 
       "<br />" + 
       "  ID: " + conn.ConsumerConnectionPoint.ID + 
       "<br />" + 
       "  Interface type: " + conn.ConsumerConnectionPoint.InterfaceType.ToString()
 + 
       "<br />" + 
       "  Control type: " + conn.ConsumerConnectionPoint.ControlType.ToString()
 + 
       "<br />" + 
       "  Allows multiple connections: " + 
          conn.ConsumerConnectionPoint.AllowsMultipleConnections.ToString() + 
       "<br />" + 
       "  Enabled: " + conn.ConsumerConnectionPoint.GetEnabled(zip1).ToString();
  }

  protected void Page_Load(object sender, EventArgs
 e)
  {
    lblConn.Text = String.Empty;
  }
</script>

<html  >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
      <asp:WebPartManager ID="mgr" runat="server" >
        <StaticConnections>
          <asp:WebPartConnection ID="conn1"
            ConsumerConnectionPointID="ZipCodeConsumer"
            ConsumerID="weather1" 
            ProviderConnectionPointID="ZipCodeProvider" 
            ProviderID="zip1" />
        </StaticConnections>      
      </asp:WebPartManager>
      <uc1:displaymodemenucs id="menu1" runat="server" />
      <asp:WebPartZone ID="WebPartZone1" runat="server">
        <ZoneTemplate>
          <aspSample:ZipCodeWebPart ID="zip1" runat="server"
            Title="Zip Code Provider"  />
          <aspSample:WeatherWebPart ID="weather1" runat="server"
 
            Title="Zip Code Consumer" />
        </ZoneTemplate>
      </asp:WebPartZone>
      <asp:ConnectionsZone ID="ConnectionsZone1" runat="server">
      </asp:ConnectionsZone>
      <asp:Button ID="Button1" runat="server" 
        Text="Dynamic Connection" 
        OnClick="Button1_Click" />      
      <br />
      <asp:Button ID="Button2" runat="server" 
        Text="Connection Point Details" 
        OnClick="Button2_Click" />
      <br />
      <asp:Label ID="lblConn" runat="server" />
    </div>
    </form>
</body>
</html>

ブラウザページ読み込んだ後、[Connection Point Details] ボタンクリックします。宣言によって接続確立されプロバイダ コネクション ポイントコンシューマ接続ポイントに関する情報表示されます。次に、[Display Mode] ドロップダウン コントロール使用してページ接続モード切り替えます1 つWebPart コントロール動詞メニュー (タイトル バー内の下向き矢印表示) で、Connect 動詞クリックします。ページ内で宣言され<asp:connectionszone> コントロールによって自動的に作成された、接続 UI表示されます。[切断] ボタンクリックして既存接続終了します。[Display Mode] コントロール使用してページブラウズ モード戻します続いて、[Dynamic Connection] ボタンクリックしプログラムによって接続作成します。[Connection Point Details] ボタンを再びクリックし2 つコネクション ポイント オブジェクト詳細表示します

.NET Framework のセキュリティ.NET Frameworkセキュリティ
継承階層継承階層
System.Object
  System.Web.UI.WebControls.WebParts.ConnectionPoint
     System.Web.UI.WebControls.WebParts.ConsumerConnectionPoint
     System.Web.UI.WebControls.WebParts.ProviderConnectionPoint
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

ConnectionPoint フィールド


ConnectionPoint プロパティ


ConnectionPoint メソッド


パブリック メソッドパブリック メソッド

プロテクト メソッドプロテクト メソッド
参照参照

関連項目

ConnectionPoint クラス
System.Web.UI.WebControls.WebParts 名前空間
WebPartConnection

その他の技術情報

Web パーツ接続概要
ASP.NET Web パーツ ページ

ConnectionPoint メンバ

Web パーツ接続で、コンシューマ コントロールプロバイダ コントロールデータ共有できるようにするコネクション ポイント オブジェクト定義するための基本クラスとして機能します

ConnectionPoint データ型公開されるメンバを以下の表に示します


パブリック フィールドパブリック フィールド
パブリック プロパティパブリック プロパティ
パブリック メソッドパブリック メソッド
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

ConnectionPoint クラス
System.Web.UI.WebControls.WebParts 名前空間
WebPartConnection

その他の技術情報

Web パーツ接続概要
ASP.NET Web パーツ ページ


英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「ConnectionPoint」の関連用語

ConnectionPointのお隣キーワード
検索ランキング

   

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



ConnectionPointのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2024 GRAS Group, Inc.RSS