ProxyWebPartManager クラスとは? わかりやすく解説

ProxyWebPartManager クラス

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

コンテンツ ページ関連付けられているマスタ ページで WebPartManager コントロール宣言されている場合に、開発者コンテンツ ページ静的接続宣言できるようにします。

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

<BindableAttribute(False)> _
Public Class ProxyWebPartManager
    Inherits Control
Dim instance As ProxyWebPartManager
[BindableAttribute(false)] 
public class ProxyWebPartManager : Control
[BindableAttribute(false)] 
public ref class ProxyWebPartManager : public
 Control
/** @attribute BindableAttribute(false) */ 
public class ProxyWebPartManager extends Control
BindableAttribute(false) 
public class ProxyWebPartManager extends
 Control
解説解説

ProxyWebPartManager コントロールは、マスタ ページWebPartManager コントロールが既に宣言されている場合コンテンツ ページ静的接続宣言するという特定のシナリオのために用意されています。

設計上、Web パーツ コントロール使用する Web ページは、ページ上のすべての Web パーツ コントロール管理する WebPartManager コントロール1 つ (1 つだけ) 含んでいる必要がありますWeb パーツ アプリケーションマスタ ページ使用するときは、通常マスタ ページWebPartManager コントロール配置します。これは、実行時にはすべてのコンテンツ ページマスタ ページマージされ、単一WebPartManager コントロールすべてのコンテンツ ページからすべての Web パーツ コントロール管理することになるからです。しかし、開発者そのようなアプリケーションコンテンツ ページ静的接続宣言するときに、制限生じ場合あります静的 Web パーツ接続は、<asp:webpartconnection> 要素<staticconnections> 要素 (この要素自体<asp:webpartmanager> 要素の子) の子として追加することによってのみ宣言できます。しかし、WebPartManager コントロールマスタ ページで既に宣言され使用できる唯一の WebPartManager コントロールとなっているため、開発者コンテンツ ページ追加WebPartManager コントロール宣言して静的接続追加できません。

このような場合には、ProxyWebPartManager コントロールWebPartManager コントロール代わりに使用されます。開発者は、コンテンツ ページ<asp:webpartmanager> 要素代わりに <asp:proxywebpartmanager> 要素宣言してから、子要素として静的接続宣言できます実行時には、ProxyWebPartManager コントロール内の接続WebPartManager コントロールの StaticConnections コレクション単純に追加され、他の接続同様に扱われます。

ProxyWebPartManager コントロールこのような特定の開発シナリオでのみ使用されるため、その機能WebPartManager クラスよりも制限されています。事実ProxyWebPartManager コントロールコンテンツ ページ内のWebPartManager コントロール静的接続格納するプロキシとして機能しますが、WebPartManager コントロールからは継承されません。このコントロールControl クラスから直接継承されいくつかの基本メンバだけをオーバーライドます。EnableTheming、Visible、および SkinID の各プロパティオーバーライドされ、そのプロパティ自体使用できないようにする値を割り当てられます。その他の継承されるプロパティは、デザイン時の動作調整するためにオーバーライドされますが、それ以外場合は、基本プロパティ同じよう動作しますこのようなプロパティには、Controls、ClientID などがありますまた、ProxyWebPartManager クラスには非継承プロパティ1 つあります。StaticConnections プロパティは、それ自体静的接続コレクション (ProxyWebPartConnectionCollection オブジェクト) を返します

メソッドに関しても同様で、ProxyWebPartManager クラスは、主に使用制限するために、一部メソッドだけをオーバーライドます。継承されFocus メソッドは、呼び出されたときに例外スローすることによって、使用できないようにします。CreateControlCollection メソッドは、常に空のコントロール コレクション返すことによって、コントロールコレクション格納できないようにします。また、OnInit メソッド基本メソッド呼び出しStaticConnections プロパティによって参照される接続コレクションWebPartManager コントロールWebPartManager.StaticConnections プロパティ割り当てます。これにより、すべてのコンテンツ ページ宣言されているすべての静的接続ロールアップされ、マスタ ページWebPartManager コントロールによって管理される接続コレクション一部となります

使用例使用例

ProxyWebPartManager クラス使用してマスタ ページ使用するアプリケーションコンテンツ ページ静的接続宣言する方法次のコード例示します。この例は、5 つ部分構成されます。

コード例最初部分は、Web ページ上の表示モードユーザー変更できるようにするユーザー コントロールです。次のソース コード.ascx ファイル保存しホストしているマスタ ページの一番上付近にある、このユーザー コントロール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 番目の部分マスタ ページです。次のソース コードコピーしてファイル保存し使用言語に応じて、MasterPageCS.master または MasterPageVB.master という名前をファイルに付けてくださいマスタ ページにはユーザー コントロール登録するための Register ディレクティブ含まれており、ページ本体ユーザー コントロール自体参照してます。また、マスタ ページは、このページおよび関連するすべてのコンテンツ ページ使用される単一<asp:webpartmanager> 要素宣言してます。マスタ ページには、コンテンツ ページ挿入されるページ内の位置宣言する <asp: contentplaceholder> 要素あります

<%@ Master Language="VB" %>
<%@ register tagprefix="uc1" 
    tagname="DisplayModeMenuVB"
    src="~/displaymodemenuvb.ascx" %>
    
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML
 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html  >
<head runat="server">
    <title>Master page with connections in
 content pages</title>
</head>
<body>
    <h2>Contoso, Ltd.</h2>
    <hr />
    <form id="form1" runat="server">
    <asp:webpartmanager runat="server" id="WebPartManager1"
 />
    <uc1:displaymodemenuvb id="menu1" runat="server"
 />
    <div>
        <asp:contentplaceholder id="ContentPlaceHolder1"
 
          runat="server" />
    </div>
    </form>
</body>
</html>
<%@ Master Language="C#" %>
<%@ register tagprefix="uc1" 
    tagname="DisplayModeMenuCS"
    src="~/displaymodemenucs.ascx" %>
    
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html  >
<head runat="server">
    <title>Master page with connections in content pages</title>
</head>
<body>
    <h2>Contoso, Ltd.</h2>
    <hr />
    <form id="form1" runat="server">
    <asp:webpartmanager runat="server" id="WebPartManager1"
 />
    <uc1:displaymodemenucs id="menu1" runat="server" />
    <div>
        <asp:contentplaceholder id="ContentPlaceHolder1" 
          runat="server" />
    </div>
    </form>
</body>
</html>

コード例4 番目の部分コンテンツ ページです。次のソース コードコピーして拡張子.aspxファイル保存してくださいコンテンツ ページPage ディレクティブには、マスタ ページ参照するための MasterFile 属性含まれています。また、このページには、接続参加し動的にコンパイルされた WebPart カスタム コントロール格納する App_Code フォルダファイル登録するための Register ディレクティブありますページ<asp:content> タグ内には、<asp:proxywebpartmanager> 要素があり、接続詳細宣言します。この要素には、<asp:webpartconnection>子要素として持つ、子要素<staticconnections>ありますページ<script> タグ内では、Button1_Click メソッドが、マスタ ページメイン WebPartManager コントロールコンテンツ ページProxyWebPartManager コントロールアクセスするコード追加し、それらの詳細一部ページ書き込みます

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

ページブラウザ読み込んだら、[WebPartManager Information] ボタンクリックしてマスタ ページWebPartManager コントロールに関する情報コンテンツ ページProxyWebPartManager コントロールに関する情報確認します。たとえば、それぞれのコントロール静的接続追跡するプロパティ (StaticConnections プロパティ) の値は同じです。また、WebPartManager コントロールにはそれが管理する WebPart コントロールの数を追跡する WebParts プロパティありますが、静的接続格納することが唯一の目的である ProxyWebPartManager コントロールにはそのようなプロパティはありません。

.NET Framework のセキュリティ.NET Frameworkセキュリティ
継承階層継承階層
System.Object
   System.Web.UI.Control
    System.Web.UI.WebControls.WebParts.ProxyWebPartManager
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
ProxyWebPartManager メンバ
System.Web.UI.WebControls.WebParts 名前空間
WebPartManager
WebPartConnection
その他の技術情報
ASP.NET Web パーツ ページ



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

辞書ショートカット

すべての辞書の索引

「ProxyWebPartManager クラス」の関連用語

ProxyWebPartManager クラスのお隣キーワード
検索ランキング

   

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



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

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

©2025 GRAS Group, Inc.RSS