Uredi

Deli z drugimi prek


WebZone.PartStyle Property

Definition

Gets style characteristics that apply to the border and contents of each Web Parts control contained by a zone.

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

Property Value

A TableStyle that contains style attributes for the Web Parts controls in the zone.

Attributes

Examples

The following code example demonstrates the use of the PartStyle property. Note that in the zone referenced in the declarative markup, there is an <asp:calendar> element and an <asp:literal> element, with both controls acting as Web Parts controls at run time because they are in a zone. After the user clicks a date on the calendar control, the page programmatically uses the PartStyle property to change the background color of all part controls in the zone to red.

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

Remarks

The style attributes apply to the border and contents of every Web Parts control in a zone. This property is read-only; however, you can set the properties of the TableStyle object it returns. This property enables you to provide a consistent style for the contents of all the controls a zone contains.

Applies to

See also