WebZone.PartChromeStyle 属性

定义

获取适用于区域所包含的 Web 部件控件的边框的样式属性。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; }
member this.PartChromeStyle : System.Web.UI.WebControls.Style
Public ReadOnly Property PartChromeStyle As Style

属性值

Style,其中包含区域所包含的 Web 部件控件的边框样式特性。A Style that contains style attributes for the borders that surround Web Parts controls contained by a zone.

属性

示例

下面的代码示例演示如何使用 PartChromeStyle 属性为区域中包含 Web 部件控件的外边框设置样式特性。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>

请注意,在浏览器中首次加载页面时,上部控件具有其自己的绿色边框,宽度为2个像素,在页面的声明性标记中设置为。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. 用户单击日历后,页面以编程方式将区域中的两个控件的边框更改为红色,并将其边框宽度设置为4像素,而上部控件则保留其原来的绿色内部边框。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.

注解

Web 部件控件可以有其自己的边框,在 PartStyle 属性中定义。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. 区域可以围绕其每个 Web 部件控件设置的外边框由 PartChromeStyle 属性确定。The outer border that a zone can place around each of its Web Parts controls is determined by the PartChromeStyle property. 此属性不取消 PartStyle 对象中包含的属性属性;它与合并或添加到它们。This property does not cancel out the property attributes contained in the PartStyle object; it is merged with or added to them. 它使区域能够为它包含的每个 Web 部件控件提供一个公共且一致的边框。It enables a zone to provide a common and consistent border for each of the Web Parts controls it contains.

重要

尽管 PartChromeStyle 样式设置主要应用于区域可以围绕其包含的控件设置的外边框,但如果在属性引用的 Style 对象上设置附加属性(例如 BackColor),则浏览器会将这些样式特性解释为用于呈现区域的表的所有子元素。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. 因此,为 PartChromeStyle 属性引用的样式对象设置 BackColor 属性对 WebPart 控件具有相同的效果,因为在 PartStyle 属性所引用的对象上设置 BackColor 属性。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.

适用于

另请参阅