Login.TitleTextStyle 属性

定义

获取对属性集合的引用,这些属性定义 Login 控件中标题文本的外观。Gets a reference to a collection of properties that define the appearance of the title text in the Login control.

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

属性值

对包含定义标题文本外观的属性的 TableItemStyle 的引用。A reference to the TableItemStyle that contains properties that define the appearance of title text.

属性

示例

下面的代码示例通过设置 TitleTextStyle 属性引用的 TableItemStyle 对象的属性来设置标题的文本颜色、背景色和字体粗细。The following code example sets the text color, background color, and font weight of the title by setting properties of the TableItemStyle object referenced by the TitleTextStyle property.

重要

此示例包含一个文本框,该文本框接受用户输入,这是一个潜在的安全威胁。This example contains a text box that accepts user input, which is a potential security threat. 默认情况下,ASP.NET 网页验证用户输入是否不包含脚本或 HTML 元素。By default, ASP.NET Web pages validate that user input does not include script or HTML elements. 有关详细信息,请参阅脚本侵入概述For more information, see Script Exploits Overview.

<%@ 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 changeClick(object sender, EventArgs e)
{
    Login1.TitleText = newTitle.Text;
}

void OnLoginError(object sender, EventArgs e)
{
    Login1.TitleTextStyle.BackColor = System.Drawing.Color.Red;
}

</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
        <form id="form1" runat="server">
            <table style="text-align:center; border:1">
                <tr>
                    <td>
                        Title Text:
                    </td>
                    <td>
                        <asp:TextBox id="newTitle" runat="server">Login</asp:TextBox></td>
                    <td>
                        <asp:Button id="change" runat="server" onClick="changeClick" Text="Change"></asp:Button></td>
                </tr>
                <tr>
                    <td colspan="3" align="center">
                        <asp:Login id="Login1" runat="server" 
                            TitleText="Log In Now"
                            OnLoginError="OnLoginError">
                            <TitleTextStyle 
                                Font-Bold="True" 
                                ForeColor="#0000C0" 
                                BackColor="#E0E0E0">
                        </TitleTextStyle>
                        </asp:Login>
                    </td>
                </tr>
            </table>
        </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 changeClick(ByVal sender As Object, ByVal e As EventArgs)
    Login1.TitleText = newTitle.Text
End Sub

Sub OnLoginError(ByVal sender As Object, ByVal e As EventArgs)
    Login1.TitleTextStyle.BackColor = System.Drawing.Color.Red
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
        <form id="form1" runat="server">
            <table style="text-align:center; border:1">
                <tr>
                    <td>
                        Title Text:
                    </td>
                    <td>
                        <asp:TextBox id="newTitle" runat="server">Login</asp:TextBox></td>
                    <td>
                        <asp:Button id="change" runat="server" onClick="changeClick" Text="Change"></asp:Button></td>
                </tr>
                <tr>
                    <td colspan="3" align="center">
                        <asp:Login id="Login1" runat="server" 
                            TitleText="Log In Now"                            
                            OnLoginError="OnLoginError">
                            <TitleTextStyle 
                                Font-Bold="True" 
                                ForeColor="#0000C0" 
                                BackColor="#E0E0E0">
                        </TitleTextStyle>
                        </asp:Login>
                    </td>
                </tr>
            </table>
        </form>
    </body>
</html>

注解

TitleTextStyle 属性获取对 TableItemStyle 对象的引用,使用该对象可以更改 TitleText 属性中包含的标题的外观。The TitleTextStyle property gets a reference to a TableItemStyle object that you use to change the appearance of the title contained in the TitleText property.

TitleTextStyle 属性定义 Login 控件中标题的外观。The TitleTextStyle property defines the appearance of the title in the Login control. 此属性是只读的;但是,您可以设置它返回的 TableItemStyle 对象的属性。This property is read-only; however, you can set the properties of the TableItemStyle object it returns. 您可以以声明方式设置这些属性 Property-Subproperty,其中 Subproperty 表示 TableItemStyle 类的属性(例如 TitleStyle-ForeColor)。You can set these properties declaratively in the form Property-Subproperty, where Subproperty represents a property of the TableItemStyle class (for example, TitleStyle-ForeColor). 您可以以编程方式在 Property.Subproperty 格式设置属性(例如,TitleStyle.ForeColor)。You can set the property programmatically in the form Property.Subproperty (for example, TitleStyle.ForeColor).

常见设置包括自定义背景色、文本颜色和字体属性。Common settings include custom background color, text color, and font properties. TitleTextStyle 属性定义 TitleText 属性的外观。The TitleTextStyle property defines the appearance of the TitleText property.

TitleTextStyle 属性的样式设置与 Login 控件的样式设置进行合并。The style settings for the TitleTextStyle property are merged with the style settings for the Login control. TitleTextStyle 属性中所做的任何设置都将覆盖 Login 控件的属性中的相应设置。Any settings made in the TitleTextStyle property override the corresponding settings in properties of the Login control.

以下 Login 样式属性被 TitleTextStyle 设置重写:The following Login style properties are overridden by TitleTextStyle settings:

使用模板定义 Login 控件的外观时,TitleTextStyle 属性不起作用。When you use templates to define the appearance of the Login control, the TitleTextStyle property has no effect.

适用于

另请参阅