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

WebPartZoneCollection クラス

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

WebPartZone コントロール読み取り専用コレクション含みます

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

Public NotInheritable Class
 WebPartZoneCollection
    Inherits ReadOnlyCollectionBase
Dim instance As WebPartZoneCollection
public sealed class WebPartZoneCollection :
 ReadOnlyCollectionBase
public ref class WebPartZoneCollection sealed
 : public ReadOnlyCollectionBase
public final class WebPartZoneCollection extends
 ReadOnlyCollectionBase
public final class WebPartZoneCollection extends
 ReadOnlyCollectionBase
解説解説

WebPartZoneCollection クラスには、Web パーツ ページ存在する WebPartZone コントロールコレクション含まれます。主に WebPartManager コントロールによって、すべてのゾーン追跡および管理使用されます。WebPartManager コントロールは、ページ上のゾーンコレクションへの参照を、その読み取り専用Zones プロパティ保持します

WebPartZoneCollection クラスは、複数ゾーンまたはその内容に対して同時に操作実行する場合、または特定のゾーン検索してその内容確認または変更する場合に便利です。ゾーン自体コレクション読み取り専用で、コレクション オブジェクト自体サイズ変更できませんが、コレクション内の個別ゾーンへの参照取得することはできますまた、個別ゾーン オブジェクトへの参照保持している場合はそのプロパティ値を変更できます

WebPartZoneCollection クラスには、2 つコンストラクタあります1 つ目の WebPartZoneCollection は、新しWebPartZoneCollection の空のインスタンス初期化するだけです。2 つ目の WebPartZoneCollection(ICollection) は、ゾーン既存コレクションを渡すことによってコレクション初期化します。

WebPartZoneCollection クラスには、Item プロパティ含まれています。このプロパティでは、文字列識別子を渡すことによってコレクション内の WebPartZone コントロール検索できますゾーン検索するには、文字列識別子と WebPartZoneBase ゾーンID プロパティの値が照合されます。

WebPartZoneCollection クラスには、その内容確認またはアクセス便利なメソッド複数あります。Contains メソッドは、特定のゾーンコレクション存在するかどうか判断しますCopyTo メソッドは、コレクションWebPartZoneBase オブジェクト配列コピーします最後に、IndexOf メソッドは、コレクション内の特定のゾーンインデックス返します

使用例使用例

WebPartZoneCollection クラス使用方法を示すコード例次に示しますコード例は、3 つの部分構成されます。2 つコード セクション残り例の実行方法説明です。

コード例最初部分は、それぞれにサーバー コントロール1 つ含む 3 つの WebPartZone コントロールがある Web ページです。これらのサーバー コントロールはすべて標準ASP.NET コントロールですが、WebPartZone ゾーン内に配置されているので、実行時には WebPart コントロールとして機能できます

<%@ Page Language="vb" 
    Codefile="webpartzonecollection_overview.vb" 
    Inherits="webpartzonecollection_overview"
 %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML
 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
<html  >
<head id="Head1" runat="server">
    <title>WebPartZoneCollection Demo</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <asp:WebPartManager ID="mgr" runat="server"
 />
    <asp:Table ID="Table1" runat="server">
      <asp:TableRow>
        <asp:TableCell>
          <asp:Label ID="lblZone1" runat="server"
 Font-Bold="true">
            WebPartZone1 Contents
          </asp:Label>
          <asp:WebPartZone ID="WebPartZone1" runat="server"
 Width="230">
            <ZoneTemplate>
              <asp:BulletedList 
                ID="BulletedList1" 
                Runat="server"
                DisplayMode="HyperLink" 
                Title="Favorite Links" CatalogIconImageUrl="Mine.gif">
                <asp:ListItem Value="http://msdn.microsoft.com">
                  MSDN
                </asp:ListItem>
                <asp:ListItem Value="http://www.asp.net">
                  ASP.NET
                </asp:ListItem>
                <asp:ListItem Value="http://www.msn.com">
                  MSN
                </asp:ListItem>
              </asp:BulletedList>      
            </ZoneTemplate>
          </asp:WebPartZone>
          <div>
          <asp:Label ID="lblZone2" runat="server"
 Font-Bold="true">
            WebPartZone2 Contents
          </asp:Label>          
          </div>
          <asp:WebPartZone ID="WebPartZone2" runat="server"
 Width="230">
            <ZoneTemplate>
              <asp:Calendar ID="Calendar1" runat="server"
 
                Title="My Calendar" />
            </ZoneTemplate>
          </asp:WebPartZone> 
        </asp:TableCell>
        <asp:TableCell VerticalAlign="top">
 
          <asp:Label ID="lblZone3" runat="server"
 Font-Bold="true">
            WebPartZone3 Contents
          </asp:Label>
          <asp:WebPartZone ID="WebPartZone3" runat="server">
            <ZoneTemplate>
              <asp:Table runat="server" ID="table2"
 
                Title="Employee Extensions">
                <asp:TableHeaderRow>
                  <asp:TableHeaderCell>Employee Name</asp:TableHeaderCell>
                  <asp:TableHeaderCell>Extension</asp:TableHeaderCell>
                </asp:TableHeaderRow>
                <asp:TableRow>
                  <asp:TableCell>Alberts, Amy</asp:TableCell>
                  <asp:TableCell>x9764</asp:TableCell>
                </asp:TableRow>                
                <asp:TableRow>
                  <asp:TableCell>Hanif, Karim</asp:TableCell>
                  <asp:TableCell>x3240</asp:TableCell>
                </asp:TableRow>
                <asp:TableRow>
                  <asp:TableCell>Penor, Lori</asp:TableCell>
                  <asp:TableCell>x4165</asp:TableCell>
                </asp:TableRow>
              </asp:Table>
            </ZoneTemplate>
          </asp:WebPartZone>
        </asp:TableCell>
      </asp:TableRow>
    </asp:Table>
    </div>
    <hr />
    <asp:Table ID="Table3" runat="server">
      <asp:TableRow>
        <asp:TableCell>
          <asp:Button ID="Button1" runat="server"
 Width ="200" 
            Text="Total Zone Count" OnClick="Button1_Click"
 />
          <br />
          <asp:Button ID="Button2" runat="server"
 Width ="200"
            Text="Coll. Contains WebPartZone2" OnClick="Button2_Click"
 />
          <br />
          <asp:Button ID="Button3" runat="server"
 Width ="200"
            Text="Zone Names from Array" OnClick="Button3_Click"
 />
          <br />
          <asp:Button ID="Button4" runat="server"
 Width ="200"
            Text="WebPartZone1 Index" OnClick="Button4_Click"
 />  
          <br />
          <asp:Button ID="Button5" runat="server"
 Width ="200"
            Text="Toggle Verb Render Mode" OnClick="Button5_Click"
 />
        </asp:TableCell>
        <asp:TableCell HorizontalAlign="right"
 Width="200" 
          VerticalAlign="top">
          <asp:Label ID="Label1" runat="server"
 Font-Bold="true" />
        </asp:TableCell>  
      </asp:TableRow>
    </asp:Table>
    </form>
</body>
</html>
<%@ Page Language="C#" 
    Codefile="webpartzonecollection_overview.cs" 
    Inherits="webpartzonecollection_overview" %>

<!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>WebPartZoneCollection Demo</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <asp:WebPartManager ID="mgr" runat="server" />
    <asp:Table runat="server">
      <asp:TableRow>
        <asp:TableCell>
          <asp:Label ID="lblZone1" runat="server" Font-Bold="true">
            WebPartZone1 Contents
          </asp:Label>
          <asp:WebPartZone ID="WebPartZone1" runat="server"
 Width="230">
            <ZoneTemplate>
              <asp:BulletedList 
                ID="BulletedList1" 
                Runat="server"
                DisplayMode="HyperLink" 
                Title="Favorite Links" CatalogIconImageUrl="Mine.gif">
                <asp:ListItem Value="http://msdn.microsoft.com">
                  MSDN
                </asp:ListItem>
                <asp:ListItem Value="http://www.asp.net">
                  ASP.NET
                </asp:ListItem>
                <asp:ListItem Value="http://www.msn.com">
                  MSN
                </asp:ListItem>
              </asp:BulletedList>      
            </ZoneTemplate>
          </asp:WebPartZone>
          <div>
          <asp:Label ID="lblZone2" runat="server" Font-Bold="true">
            WebPartZone2 Contents
          </asp:Label>          
          </div>
          <asp:WebPartZone ID="WebPartZone2" runat="server"
 Width="230">
            <ZoneTemplate>
              <asp:Calendar ID="Calendar1" runat="server"
 
                Title="My Calendar" />
            </ZoneTemplate>
          </asp:WebPartZone> 
        </asp:TableCell>
        <asp:TableCell VerticalAlign="top"> 
          <asp:Label ID="lblZone3" runat="server" Font-Bold="true">
            WebPartZone3 Contents
          </asp:Label>
          <asp:WebPartZone ID="WebPartZone3" runat="server">
            <ZoneTemplate>
              <asp:Table runat="server" ID="table1" 
                Title="Employee Extensions">
                <asp:TableHeaderRow>
                  <asp:TableHeaderCell>Employee Name</asp:TableHeaderCell>
                  <asp:TableHeaderCell>Extension</asp:TableHeaderCell>
                </asp:TableHeaderRow>
                <asp:TableRow>
                  <asp:TableCell>Alberts, Amy</asp:TableCell>
                  <asp:TableCell>x9764</asp:TableCell>
                </asp:TableRow>                
                <asp:TableRow>
                  <asp:TableCell>Hanif, Karim</asp:TableCell>
                  <asp:TableCell>x3240</asp:TableCell>
                </asp:TableRow>
                <asp:TableRow>
                  <asp:TableCell>Penor, Lori</asp:TableCell>
                  <asp:TableCell>x4165</asp:TableCell>
                </asp:TableRow>
              </asp:Table>
            </ZoneTemplate>
          </asp:WebPartZone>
        </asp:TableCell>
      </asp:TableRow>
    </asp:Table>
    </div>
    <hr />
    <asp:Table runat="server">
      <asp:TableRow>
        <asp:TableCell>
          <asp:Button ID="Button1" runat="server" Width ="200"
 
            Text="Total Zone Count" OnClick="Button1_Click" />
          <br />
          <asp:Button ID="Button2" runat="server" Width ="200"
            Text="Coll. Contains WebPartZone2" OnClick="Button2_Click"
 />
          <br />
          <asp:Button ID="Button3" runat="server" Width ="200"
            Text="Zone Names from Array" OnClick="Button3_Click"
 />
          <br />
          <asp:Button ID="Button4" runat="server" Width ="200"
            Text="WebPartZone1 Index" OnClick="Button4_Click"
 />  
          <br />
          <asp:Button ID="Button5" runat="server" Width ="200"
            Text="Toggle Verb Render Mode" OnClick="Button5_Click"
 />
        </asp:TableCell>
        <asp:TableCell HorizontalAlign="right" Width="200"
 
          VerticalAlign="top">
          <asp:Label ID="Label1" runat="server" Font-Bold="true"
 />
        </asp:TableCell>  
      </asp:TableRow>
    </asp:Table>
    </form>
</body>
</html>

コード例2 番目の部分は、WebPartZoneCollection クラス使用を示すコードを含む部分クラスです。このコードは、Web ページイベント処理します

Imports System
Imports System.Data
Imports System.Configuration
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls


Partial Public Class webpartzonecollection_overview

  Inherits Page

  Protected Sub Button1_Click(ByVal
 sender As Object, ByVal
 e As EventArgs)
    Label1.Text = String.Empty
    Label1.Text = "WebPartZone Count:  " & mgr.Zones.Count

  End Sub


  Protected Sub Button2_Click(ByVal
 sender As Object, ByVal
 e As EventArgs)
    Label1.Text = String.Empty
    Label1.Text = mgr.Zones.Contains(WebPartZone2).ToString()

  End Sub

  Protected Sub Button3_Click(ByVal
 sender As Object, ByVal
 e As EventArgs)
    Label1.Text = String.Empty
    Dim zoneArray(mgr.Zones.Count) As WebPartZoneBase
    mgr.Zones.CopyTo(zoneArray, 0)
    Label1.Text = zoneArray(2).ID
    Label1.Text += ", " & zoneArray(1).ID
    Label1.Text += ", " & zoneArray(0).ID

  End Sub

  Protected Sub Button4_Click(ByVal
 sender As Object, ByVal
 e As EventArgs)
    Label1.Text = String.Empty
    Label1.Text = "WebPartZone1 index:  " & mgr.Zones.IndexOf(WebPartZone1)

  End Sub

  Protected Sub Button5_Click(ByVal
 sender As Object, ByVal
 e As EventArgs)
    Label1.Text = String.Empty

    Dim zoneCollection As WebPartZoneCollection
 = mgr.Zones
    Dim zone As WebPartZone
    For Each zone In zoneCollection
      If zone.WebPartVerbRenderMode = WebPartVerbRenderMode.Menu
 Then
        zone.WebPartVerbRenderMode = WebPartVerbRenderMode.TitleBar
      Else
        zone.WebPartVerbRenderMode = WebPartVerbRenderMode.Menu
      End If
    Next zone

  End Sub

End Class
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class webpartzonecollection_overview
 : System.Web.UI.Page
{

  protected void Button1_Click(object sender,
 EventArgs e)
  {
    Label1.Text = String.Empty;
    Label1.Text = "WebPartZone Count:  " + mgr.Zones.Count;
  }

  protected void Button2_Click(object sender,
 EventArgs e)
  {
    Label1.Text = String.Empty;
    Label1.Text = mgr.Zones.Contains(WebPartZone2).ToString();
  }

  protected void Button3_Click(object sender,
 EventArgs e)
  {
    Label1.Text = String.Empty;
    WebPartZoneBase[] zoneArray = new WebPartZoneBase[mgr.Zones.Count];
    mgr.Zones.CopyTo(zoneArray, 0);
    Label1.Text = zoneArray[2].ID;
    Label1.Text += ", " + zoneArray[1].ID;
    Label1.Text += ", " + zoneArray[0].ID;
  }

  protected void Button4_Click(object sender,
 EventArgs e)
  {
    Label1.Text = String.Empty;
    Label1.Text = "WebPartZone1 index:  " + mgr.Zones.IndexOf(WebPartZone1);
  }

  protected void Button5_Click(object sender,
 EventArgs e)
  {
    Label1.Text = String.Empty;

    WebPartZoneCollection zoneCollection = mgr.Zones;
    foreach (WebPartZone zone in zoneCollection)
    {

      if (zone.WebPartVerbRenderMode == WebPartVerbRenderMode.Menu)
        zone.WebPartVerbRenderMode = WebPartVerbRenderMode.TitleBar;
      else
        zone.WebPartVerbRenderMode = WebPartVerbRenderMode.Menu;
    }
  }
}

ブラウザページ読み込みます。3 つの WebPartZone ゾーンが、格納しているサーバー コントロールと共に表示されます。ページ下部には、複数ボタンがあり、それぞれWebPartZoneCollection オブジェクト使用する動作デモンストレーションます。ボタンクリックしてゾーンその内容対す効果確認しますWebPartZoneCollection オブジェクトいくつかの側面を示す各ボタン関連付けられたコード表示するには、上記のこのコード例2 番目の部分として参照される部分クラス ファイルコード表示します

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

WebPartZoneCollection コンストラクタ ()

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

WebPartZoneCollection クラスの空のインスタンス初期化します。

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

Dim instance As New WebPartZoneCollection
public WebPartZoneCollection ()
public:
WebPartZoneCollection ()
public WebPartZoneCollection ()
public function WebPartZoneCollection ()
解説解説
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

WebPartZoneCollection コンストラクタ (ICollection)

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

WebPartZoneCollection クラスインスタンスを、WebPartZone オブジェクトコレクションを渡すことによって初期化します。

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

Public Sub New ( _
    webPartZones As ICollection _
)
Dim webPartZones As ICollection

Dim instance As New WebPartZoneCollection(webPartZones)
public WebPartZoneCollection (
    ICollection webPartZones
)
public:
WebPartZoneCollection (
    ICollection^ webPartZones
)
public WebPartZoneCollection (
    ICollection webPartZones
)
public function WebPartZoneCollection (
    webPartZones : ICollection
)

パラメータ

webPartZones

WebPartZone オブジェクトの ICollection。

例外例外
例外種類条件

ArgumentNullException

ゾーンコレクションnull 参照 (Visual Basic では Nothing) です。

解説解説
使用例使用例

WebPartZoneCollection コンストラクタ使用方法次のコード例示します。この例の完全なコードは、WebPartZoneCollection概要にある「例」のセクション参照してください

コード次のセクションでは、Zones プロパティの値を取得することによって、WebPartZoneCollection オブジェクト変数割り当ててます。必要な場合は、Zones プロパティからすべてのゾーン割り当てるではなくページすべてのゾーンサブセット格納する WebPartZoneBase オブジェクト配列作成し、その配列新しWebPartZoneCollection オブジェクト割り当てることができます

Protected Sub Button5_Click(ByVal
 sender As Object, ByVal
 e As EventArgs)
  Label1.Text = String.Empty

  Dim zoneCollection As WebPartZoneCollection
 = mgr.Zones
  Dim zone As WebPartZone
  For Each zone In zoneCollection
    If zone.WebPartVerbRenderMode = WebPartVerbRenderMode.Menu
 Then
      zone.WebPartVerbRenderMode = WebPartVerbRenderMode.TitleBar
    Else
      zone.WebPartVerbRenderMode = WebPartVerbRenderMode.Menu
    End If
  Next zone

End Sub
protected void Button5_Click(object sender,
 EventArgs e)
{
  Label1.Text = String.Empty;

  WebPartZoneCollection zoneCollection = mgr.Zones;
  foreach (WebPartZone zone in zoneCollection)
  {

    if (zone.WebPartVerbRenderMode == WebPartVerbRenderMode.Menu)
      zone.WebPartVerbRenderMode = WebPartVerbRenderMode.TitleBar;
    else
      zone.WebPartVerbRenderMode = WebPartVerbRenderMode.Menu;
  }
}

コレクション作成した後は、コレクション反復処理して、格納されているすべてのゾーンまたはその内容に対して操作実行できますプログラム例実行するには、ブラウザページ読み込み各ゾーンの [Toggle Verb Render Mode] ボタンクリックします。これによって、ゾーン内のサーバー コントロールタイトル バー動詞表示方法変更されます。動詞は、ドロップダウン メニューに、またはタイトル バー直接リンクとして表示できます

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

WebPartZoneCollection コンストラクタ

WebPartZoneCollection クラス新しインスタンス初期化します。

WebPartZoneCollection コンストラクタは、WebPartManager コントロールWeb パーツ コントロール セット内の他のコントロール、またはカスタム開発者コードによって、Web パーツ ページ上に存在する WebPartZone コントロール読み取り専用コレクション作成するために使用されます。

ASP.NET Web パーツ ページ
オーバーロードの一覧オーバーロードの一覧
名前 説明
WebPartZoneCollection () WebPartZoneCollection クラスの空のインスタンス初期化します。
WebPartZoneCollection (ICollection) WebPartZoneCollection クラスインスタンスを、WebPartZone オブジェクトコレクションを渡すことによって初期化します。
参照参照

関連項目

WebPartZoneCollection クラス
WebPartZoneCollection メンバ
System.Web.UI.WebControls.WebParts 名前空間

その他の技術情報

ASP.NET Web パーツ ページ
ASP.NET Web パーツ ページ

WebPartZoneCollection プロパティ


パブリック プロパティパブリック プロパティ

プロテクト プロパティプロテクト プロパティ
  名前 説明
プロテクト プロパティ InnerList  ReadOnlyCollectionBase インスタンス格納されている要素リスト取得します。 ( ReadOnlyCollectionBase から継承されます。)
参照参照

関連項目

WebPartZoneCollection クラス
System.Web.UI.WebControls.WebParts 名前空間
WebPartManager.Zones プロパティ

その他の技術情報

ASP.NET Web パーツ ページ

WebPartZoneCollection メソッド


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

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

関連項目

WebPartZoneCollection クラス
System.Web.UI.WebControls.WebParts 名前空間
WebPartManager.Zones プロパティ

その他の技術情報

ASP.NET Web パーツ ページ

WebPartZoneCollection メンバ

WebPartZone コントロール読み取り専用コレクション含みます

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


パブリック コンストラクタパブリック コンストラクタ
  名前 説明
パブリック メソッド WebPartZoneCollection オーバーロードされます。 WebPartZoneCollection クラス新しインスタンス初期化します。
パブリック プロパティパブリック プロパティ
プロテクト プロパティプロテクト プロパティ
  名前 説明
プロテクト プロパティ InnerList  ReadOnlyCollectionBase インスタンス格納されている要素リスト取得します。(ReadOnlyCollectionBase から継承されます。)
パブリック メソッドパブリック メソッド
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

WebPartZoneCollection クラス
System.Web.UI.WebControls.WebParts 名前空間
WebPartManager.Zones プロパティ

その他の技術情報

ASP.NET Web パーツ ページ



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

辞書ショートカット

すべての辞書の索引

「WebPartZoneCollection」の関連用語

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

   

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



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

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

©2025 GRAS Group, Inc.RSS