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

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

WebPartManager.Zones プロパティ

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

Web ページ上のすべての WebPartZoneBase ゾーンコレクションへの参照取得します

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

Public ReadOnly Property
 Zones As WebPartZoneCollection
Dim instance As WebPartManager
Dim value As WebPartZoneCollection

value = instance.Zones
public WebPartZoneCollection Zones { get; }
public:
property WebPartZoneCollection^ Zones {
    WebPartZoneCollection^ get ();
}
/** @property */
public WebPartZoneCollection get_Zones ()
public function get Zones
 () : WebPartZoneCollection

プロパティ
WebPartZoneBase ゾーンセット参照する WebPartZoneCollection。

解説解説
使用例使用例

プログラムZones プロパティ使用して個々WebPartZoneBase ゾーン コントロールアクセスする方法コード例次に示しますWeb ページ宣言マークアップには 2 つ<asp:webpartzone> 要素があり、それぞれにサーバー コントロール含まれています。ページ<script> セクションでは、コードZones プロパティ使用して個々ゾーンアクセスし、すべてのゾーン IDリストして 2 番目のゾーン背景色変更します

<%@ Page Language="C#" %>

<script runat="server">

  protected void Button1_Click(object sender,
 EventArgs e)
  {
    foreach (WebPartZone zone in WebPartManager1.Zones)
    {
      Label1.Text += zone.ID + "<br />";
    }
  }

  protected void Button2_Click(object sender,
 EventArgs e)
  {
    WebPartManager1.Zones["WebPartZone2"].BackColor
 = System.Drawing.Color.LightBlue;
  }
</script>

<html  >
<head id="Head1" runat="server">
</head>
<body>
    <form id="form1" runat="server">
      <!-- Reference the WebPartManager control. -->
    <asp:WebPartManager ID="WebPartManager1" runat="server"
 />
    <div>
      <asp:WebPartZone ID="WebPartZone1" runat="server">
        <ZoneTemplate>
          <asp:BulletedList 
            DisplayMode="HyperLink" 
            ID="BulletedList1" 
            runat="server"
            Title="My Links"
            ExportMode="All">
            <asp:ListItem Value="http://www.microsoft.com">
            Microsoft
            </asp:ListItem>
            <asp:ListItem Value="http://www.msn.com">
            MSN
            </asp:ListItem>
            <asp:ListItem Value="http://www.contoso.com">
            Contoso Corp.
            </asp:ListItem>
          </asp:BulletedList>
        </ZoneTemplate>
      </asp:WebPartZone>
      <asp:WebPartZone ID="WebPartZone2" runat="server">
        <ZoneTemplate>
          <asp:Calendar ID="Calendar1" runat="server"
 
            Title="My Calendar" />        
        </ZoneTemplate>
      </asp:WebPartZone>
      <hr />
      <asp:Button ID="Button1" runat="server"
 
        Text="List Zone IDs" 
        OnClick="Button1_Click" />
      <asp:Button ID="Button2" runat="server"
 
        Text="Change Zone BackColor" 
        OnClick="Button2_Click" />  
      <br />
      <asp:Label ID="Label1" runat="server"
 text="" />
    </div>
    </form>
</body>
</html>
<%@ Page Language="vb" %>

<script runat="server">

  Protected Sub Button1_Click(ByVal sender As Object, _
    ByVal e As System.EventArgs)
    Dim zone As WebPartZone
    For Each zone In WebPartManager1.Zones
      Label1.Text += zone.ID & "<br />"
    Next
  End Sub

  Protected Sub Button2_Click(ByVal sender As Object, _
    ByVal e As System.EventArgs)
    WebPartManager1.Zones("WebPartZone2").BackColor = _
      System.Drawing.Color.LightBlue
  End Sub
</script>

<html  >
<head id="Head1" runat="server">
</head>
<body>
    <form id="form1" runat="server">
      <!-- Reference the WebPartManager control. -->
    <asp:WebPartManager ID="WebPartManager1" runat="server"
 />
    <div>
      <asp:WebPartZone ID="WebPartZone1" runat="server">
        <ZoneTemplate>
          <asp:BulletedList 
            DisplayMode="HyperLink" 
            ID="BulletedList1" 
            runat="server"
            Title="My Links"
            ExportMode="All">
            <asp:ListItem Value="http://www.microsoft.com">
            Microsoft
            </asp:ListItem>
            <asp:ListItem Value="http://www.msn.com">
            MSN
            </asp:ListItem>
            <asp:ListItem Value="http://www.contoso.com">
            Contoso Corp.
            </asp:ListItem>
          </asp:BulletedList>
        </ZoneTemplate>
      </asp:WebPartZone>
      <asp:WebPartZone ID="WebPartZone2" runat="server">
        <ZoneTemplate>
          <asp:Calendar ID="Calendar1" runat="server" 
            Title="My Calendar" />        
        </ZoneTemplate>
      </asp:WebPartZone>
      <hr />
      <asp:Button ID="Button1" runat="server" 
        Text="List Zone IDs" 
        OnClick="Button1_Click" />
      <asp:Button ID="Button2" runat="server" 
        Text="Change Zone BackColor" 
        OnClick="Button2_Click" />  
      <br />
      <asp:Label ID="Label1" runat="server" text=""
 />
    </div>
    </form>
</body>
</html>

コード例機能するには、Web.config ファイル設定追加してWeb パーツ記述ファイルエクスポートできるようにする必要があります。このコード例Web ページと同じディレクトリ内に Web.config ファイル存在することを確認してください<system.web> セクション内に、次のマークアップのように、true設定されenableExport 属性を持つ <webParts> 要素存在することを確認します

<webParts enableExport="true">

...

</webParts>

ブラウザページ読み込んだ後、[List Zone IDs] をクリックすると、コードZones プロパティ使用してコレクション内のすべてのゾーンIDリストます。[Change Zone BackColor] をクリックすると、コード2 番目のゾーン背景色変更します

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
WebPartManager クラス
WebPartManager メンバ
System.Web.UI.WebControls.WebParts 名前空間


このページでは「.NET Framework クラス ライブラリ リファレンス」からWebPartManager.Zones プロパティを検索した結果を表示しています。
Weblioに収録されているすべての辞書からWebPartManager.Zones プロパティを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からWebPartManager.Zones プロパティ を検索

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

辞書ショートカット

すべての辞書の索引

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

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

   

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



WebPartManager.Zones プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS