WebZone.HeaderText 属性

定义

获取或设置区域的页眉区的文本。Gets or sets the text for the header area of a zone.

public:
 virtual property System::String ^ HeaderText { System::String ^ get(); void set(System::String ^ value); };
public virtual string HeaderText { get; set; }
member this.HeaderText : string with get, set
Public Overridable Property HeaderText As String

属性值

一个字符串,包含区域的页眉文本。A string that contains the header text for the zone. 默认值为空字符串("")。The default is an empty string ("").

示例

下面的代码示例演示如何使用 HeaderText 属性。The following code example demonstrates the use of the HeaderText property. 请注意,声明性标记中有两个区域,第二个 <asp:webpartzone> 元素为空。Note that there are two zones in the declarative markup, and the second <asp:webpartzone> element is empty.

<%@ page language="C#" %>
<%@ register TagPrefix="uc1" 
  TagName="DisplayModeMenuCS" 
  Src="DisplayModeMenuCS.ascx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
  <form id="Form1" runat="server">
    <asp:webpartmanager id="WebPartManager1" runat="server" />
    <uc1:DisplayModeMenuCS ID="DisplayModeMenu1" runat="server" />
    <asp:webpartzone
      id="WebPartZone1"
      runat="server">
        <zonetemplate>
          <asp:Calendar ID="cal1" Runat="server" Title="My Calendar" />
        </zonetemplate>
    </asp:webpartzone>
    <asp:webpartzone
      id="WebPartZone2"
      runat="server" 
      HeaderText="My Zone Header">
    </asp:webpartzone>
  </form>
</body>
</html>
<%@ page language="VB" %>
<%@ register TagPrefix="uc1" 
  TagName="DisplayModeMenuVB" 
  Src="DisplayModeMenuVB.ascx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
  <form id="Form1" runat="server">
    <asp:webpartmanager id="WebPartManager1" runat="server" />
    <uc1:DisplayModeMenuVB ID="DisplayModeMenu1" runat="server" />
    <asp:webpartzone
      id="WebPartZone1"
      runat="server">
        <zonetemplate>
          <asp:Calendar ID="cal1" Runat="server" Title="My Calendar" />
        </zonetemplate>
    </asp:webpartzone>
    <asp:webpartzone
      id="WebPartZone2"
      runat="server" 
      HeaderText="My Zone Header">
    </asp:webpartzone>
  </form>
</body>
</html>

在浏览器中,可以将页面切换到设计模式,以查看为区域的标题区域中显示的 HeaderText 属性提供的文本。In a browser, you can switch the page to design mode to see the text supplied for the HeaderText property displayed in the header area of the zone. 有关如何更改页显示模式的详细信息,请参阅演练:更改 Web 部件页上的显示模式For details on how to change page display modes, see Walkthrough: Changing Display Modes on a Web Parts Page.

注解

当网页进入特定显示模式时,将显示区域的 HeaderText 属性的内容。The contents of a zone's HeaderText property are displayed when a Web page enters certain display modes. 例如,在具有 WebPartZone 控件的页上,当页面进入编辑、目录或设计模式时,分配给 HeaderText 属性的文本将变为可见。For example, on a page that has a WebPartZone control, the text assigned to the HeaderText property becomes visible when the page enters edit, catalog, or design mode.

设置此属性后,可以使用设计器工具自动将此属性的值保存到资源文件中。The value of this property, when set, can be saved automatically to a resource file by using a designer tool. 有关详细信息,请参阅 LocalizableAttribute全球化和本地化For more information, see LocalizableAttribute and Globalization and Localization.

适用于

另请参阅