Редагувати

Поділитися через


WebZone.PartChromeStyle Property

Definition

Gets style characteristics that apply to the borders of Web Parts controls contained by a zone.

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

Property Value

A Style that contains style attributes for the borders that surround Web Parts controls contained by a zone.

Attributes

Examples

The following code example demonstrates the use of the PartChromeStyle property to set style attributes for the outer borders of Web Parts controls contained in a zone.

<%@ 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.PartChromeStyle.BorderColor = System.Drawing.Color.Red;
    WebPartZone1.PartChromeStyle.BorderWidth = 4;
  }
</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" 
            BorderColor="#00cc99" 
            BorderWidth="2" />
          <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.PartChromeStyle.BorderColor = System.Drawing.Color.Red
    WebPartZone1.PartChromeStyle.BorderWidth = 4
  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" 
            BorderColor="#00cc99" 
            BorderWidth="2" />
          <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>

Note that when you first load the page in a browser, the upper control has its own green border with a width of 2 pixels, as set in the declarative markup for the page. After a user clicks the calendar, the page programmatically changes the borders of both controls in the zone to red, and sets their border width to 4 pixels, yet the upper control retains its original green inner border.

Remarks

A Web Parts control can have its own border, defined in the PartStyle property. The zone that contains the control can add an additional outer border around the control. The outer border that a zone can place around each of its Web Parts controls is determined by the PartChromeStyle property. This property does not cancel out the property attributes contained in the PartStyle object; it is merged with or added to them. It enables a zone to provide a common and consistent border for each of the Web Parts controls it contains.

Important

Although the PartChromeStyle style settings apply primarily to the outer border that a zone can set around the controls it contains, if you set additional properties on the Style object referenced by the property, such as BackColor, the browser interprets those style attributes as applying to all the sub-elements of the table used to render a zone. Hence, setting the BackColor property for the style object referenced by the PartChromeStyle property has the same effect on a WebPart control as setting the BackColor property on the object referenced by the PartStyle property.

Applies to

See also