Login.TitleTextStyle 属性

定义

获取对属性集合的引用,这些属性定义 Login 控件中标题文本的外观。

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; }
[<System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)>]
member this.TitleTextStyle : System.Web.UI.WebControls.TableItemStyle
Public ReadOnly Property TitleTextStyle As TableItemStyle

属性值

TableItemStyle

对包含定义标题文本外观的属性的 TableItemStyle 的引用。

属性

示例

下面的代码示例通过设置属性引用TitleTextStyle的对象的属性TableItemStyle来设置标题的文本颜色、背景色和字体粗细。

重要

此示例包含接受用户输入的文本框,这是潜在的安全威胁。 默认情况下,ASP.NET 网页验证用户输入是否不包含脚本或 HTML 元素。 有关详细信息,请参阅脚本侵入概述

<%@ 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 标题外观的对象的引用。

TitleTextStyle 属性定义控件中 Login 标题的外观。 此属性为只读;但是,可以设置它返回的对象的属性 TableItemStyle 。 可以在窗体 Property-Subproperty中以声明方式设置这些属性,其中 Subproperty 表示 TableItemStyle 类 (的属性, TitleStyle-ForeColor 例如) 。 可以在窗体 Property.Subproperty 中以编程方式设置属性 (,例如 TitleStyle.ForeColor) 。

常见设置包括自定义背景色、文本颜色和字体属性。 该 TitleTextStyle 属性定义属性的外观 TitleText

属性的 TitleTextStyle 样式设置与控件的 Login 样式设置合并。 属性 TitleTextStyle 中所做的任何设置都会覆盖控件属性 Login 中的相应设置。

以下 Login 样式属性由 TitleTextStyle 设置替代:

使用模板定义控件的外观 Login 时,该 TitleTextStyle 属性不起作用。

适用于

另请参阅