WebZone.PartStyle プロパティ

定義

ゾーンに含まれる境界線および各 Web パーツ コントロールの内容に適用されるスタイル特性を取得します。

public:
 property System::Web::UI::WebControls::TableStyle ^ PartStyle { System::Web::UI::WebControls::TableStyle ^ get(); };
[System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)]
public System.Web.UI.WebControls.TableStyle PartStyle { get; }
[<System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)>]
member this.PartStyle : System.Web.UI.WebControls.TableStyle
Public ReadOnly Property PartStyle As TableStyle

プロパティ値

ゾーンの Web パーツ コントロールのスタイル属性を含む TableStyle

属性

次のコード例では、 プロパティの使用方法を PartStyle 示します。 宣言型マークアップで参照されるゾーンには 要素と <asp:literal> 要素があり、両方のコントロールが<asp:calendar>ゾーン内にあるため、実行時に Web パーツ コントロールとして機能することに注意してください。 ユーザーが予定表コントロールの日付をクリックすると、ページはプログラムによって プロパティを PartStyle 使用して、ゾーン内のすべてのパーツ コントロールの背景色を赤に変更します。

<%@ page language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">

  void cal1_SelectionChanged(object sender, EventArgs e)
  {
    WebPartZone1.PartStyle.BackColor = 
        System.Drawing.Color.Red;
  }
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>Favorite Links</title>
</head>
<body>
  <form id="Form1" runat="server">
    <asp:webpartmanager id="WebPartManager1" runat="server" />
    <asp:webpartzone
      id="WebPartZone1"
      runat="server">
        <zonetemplate>
          <asp:Calendar 
            ID="cal1" 
            Runat="server" 
            Title="My Calendar" 
            OnSelectionChanged="cal1_SelectionChanged" />
          <asp:Literal ID="literal1" Runat="server">
            <h2>Favorite Links</h2>
            <a href="http://www.microsoft.com">Microsoft</a>
            <br />
            <a href="http://msdn.microsoft.com">MSDN</a>
          </asp:Literal>
        </zonetemplate>
    </asp:webpartzone>
  </form>
</body>
</html>
<%@ page language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
  Sub cal1_SelectionChanged(ByVal sender As Object, _
                            ByVal e As EventArgs)
    WebPartZone1.PartStyle.BackColor = _
        System.Drawing.Color.Red
  End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>Favorite Links</title>
</head>
<body>
  <form id="Form1" runat="server">
    <asp:webpartmanager id="WebPartManager1" runat="server" />
    <asp:webpartzone
      id="WebPartZone1"
      runat="server">
        <zonetemplate>
          <asp:Calendar 
            ID="cal1" 
            Runat="server" 
            Title="My Calendar" 
            OnSelectionChanged="cal1_SelectionChanged" />
          <asp:Literal ID="literal1" Runat="server">
            <h2>Favorite Links</h2>
            <a href="http://www.microsoft.com">Microsoft</a>
            <br />
            <a href="http://msdn.microsoft.com">MSDN</a>
          </asp:Literal>
        </zonetemplate>
    </asp:webpartzone>
  </form>
</body>
</html>

注釈

スタイル属性は、ゾーン内のすべての Web パーツ コントロールの境界線とコンテンツに適用されます。 このプロパティは読み取り専用です。ただし、返されるオブジェクトのプロパティを TableStyle 設定できます。 このプロパティを使用すると、ゾーンに含まれるすべてのコントロールの内容に一貫したスタイルを提供できます。

適用対象

こちらもご覧ください