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

屬性值

TableStyle

TableStyle,包含區域中 Web 組件控制項的樣式屬性。

屬性

範例

下列程式碼範例示範 如何使用 PartStyle 屬性。 請注意,在宣告式標記所參考的區域中,有一個元素和一個元素,這兩個 <asp:calendar> <asp:literal> 控制項在執行時間會當做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 物件的屬性。 這個屬性可讓您為區域包含的所有控制項內容提供一致的樣式。

適用於

另請參閱