Part.Title 属性

定义

获取或设置部件控件的标题。Gets or sets the title of a part control.

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

属性值

String

一个表示部件控件的标题的字符串。A string that represents the title of the part control. 默认值为空字符串 ("")。The default value is an empty string ("").

示例

下面的代码示例演示了部件控件中的属性的声明性用法 TitleThe following code example illustrates the declarative use of the Title property in a part control. 此示例需要自定义 WebPart 控件 TextDisplayWebPart ,该控件可在类摘要的 "示例" 部分中找到 PartThis example requires the custom WebPart control TextDisplayWebPart, which can be found in the Example section of the Part class summary.

<%@ page language="C#" %>
<%@ register tagprefix="aspSample" 
             Namespace="Samples.AspNet.CS.Controls" 
             Assembly="TextDisplayWebPartCS" %>

<!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" />
    <asp:webpartzone
      id="WebPartZone1"
      runat="server"
      backcolor="#99cccc">
        <parttitlestyle font-bold="true" forecolor="#ffffff" />
        <partstyle
          borderwidth="1px" 
          borderstyle="Solid" 
          bordercolor="#81AAF2" />
        <zonetemplate>
          <aspSample:TextDisplayWebPart 
            runat="server"   
            id="textwebpart" 
            title = "Text Content WebPart" 
            Description="A text content WebPart control."
            ChromeType="TitleAndBorder"
            width="350px" />
        </zonetemplate>
    </asp:webpartzone>
    <asp:webpartzone
      id="WebPartZone2"
      runat="server"
      backcolor="#99cccc">
        <parttitlestyle font-bold="true" forecolor="#ffffff" />
        <partstyle
          borderwidth="1px" 
          borderstyle="Solid" 
          bordercolor="#81AAF2" />
        <zonetemplate>
          <aspSample:TextDisplayWebPart 
            runat="server"   
            id="textwebpart2" 
            title = "Text Content WebPart 2" 
            Description="A text content WebPart control."
            ChromeType="TitleOnly"
            ChromeState="Minimized"
            width="350px" />
        </zonetemplate>
    </asp:webpartzone>
  </form>
</body>
</html>
<%@ page language="VB" %>
<%@ register tagprefix="aspSample" 
             Namespace="Samples.AspNet.VB.Controls" 
             Assembly="TextDisplayWebPartVB" %>

<!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" />
    <asp:webpartzone
      id="WebPartZone1"
      runat="server"
      backcolor="#99cccc">
        <parttitlestyle font-bold="true" forecolor="#ffffff" />
        <partstyle
          borderwidth="1px" 
          borderstyle="Solid" 
          bordercolor="#81AAF2" />
        <zonetemplate>
          <aspSample:TextDisplayWebPart 
            runat="server"   
            id="textwebpart" 
            title = "Text Content WebPart" 
            Description="A text content WebPart control."
            ChromeType="TitleAndBorder"
            width="350px" />
        </zonetemplate>
    </asp:webpartzone>
    <asp:webpartzone
      id="WebPartZone2"
      runat="server"
      backcolor="#99cccc">
        <parttitlestyle font-bold="true" forecolor="#ffffff" />
        <partstyle
          borderwidth="1px" 
          borderstyle="Solid" 
          bordercolor="#81AAF2" />
        <zonetemplate>
          <aspSample:TextDisplayWebPart 
            runat="server"   
            id="textwebpart2" 
            title = "Text Content WebPart 2" 
            Description="A text content WebPart control."
            ChromeType="TitleOnly"
            ChromeState="Minimized"
            width="350px" />
        </zonetemplate>
    </asp:webpartzone>
  </form>
</body>
</html>

注解

部件控件的标题栏中的可见标题文本由 Title 属性设置。The visible title text in a part control's title bar is set by the Title property. 将鼠标指针置于 WebPart 控件或区域中显示的其他服务器控件的标题栏上方时,标题文本也会显示为工具提示文本的一部分 WebPartZoneThe title text also appears as part of the ToolTip text when you position your mouse pointer over the title bar of a WebPart control or other server control that appears in a WebPartZone zone.

标题文本的样式由 PartTitleStyle 包含部件控件的区域的属性确定。The style of the title text is determined by the PartTitleStyle property of the zone that contains the part control.

如果没有为控件提供标题,则 Web 部件控件集会自动计算要用作标题的默认字符串。If you do not supply a title for a control, the Web Parts control set automatically calculates a default string to use as a title. 有关详细信息,请参阅 DisplayTitleFor more information, see DisplayTitle. 此外,还可以提供附加到标题字符串的标准副标题。Also, it is possible to provide a standard subtitle that is appended to the title string. 有关详细信息,请参阅 SubtitleFor details, see Subtitle.

设置此属性后,可以使用设计器工具自动将此属性的值保存到资源文件中。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.

继承者说明

派生类(如) WebPart 可以重写 Title ,以启用标题的用户个性化设置。Derived classes such as WebPart can override Title to enable user personalization of the title.

适用于

另请参阅