PasswordRecovery.TextBoxStyle 属性

定义

获取对样式属性集合的引用,这些属性定义 PasswordRecovery 控件中的文本框外观。

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

属性值

Style

Style 的引用,它包含定义 PasswordRecovery 控件中的文本框外观的属性。

属性

示例

如果用户输入用户名时出错,下面的代码示例将更改“用户名”文本框的外观。

重要

此示例包含接受用户输入的文本框,这是潜在的安全威胁。 默认情况下,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 PasswordRecovery1_UserLookupError(object sender, EventArgs e)
    {
        PasswordRecovery1.TextBoxStyle.BackColor = System.Drawing.Color.Red;
        PasswordRecovery1.TextBoxStyle.ForeColor = System.Drawing.Color.White;
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
<form id="form1" runat="server">
    <asp:passwordrecovery id="PasswordRecovery1" runat="server" 
        onuserlookuperror="PasswordRecovery1_UserLookupError">
        <textboxstyle backcolor="#C0FFC0"></textboxstyle>
    </asp:passwordrecovery>

</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 PasswordRecovery1_UserLookupError(ByVal sender As Object, ByVal e As System.EventArgs)
        PasswordRecovery1.TextBoxStyle.BackColor = System.Drawing.Color.Red
        PasswordRecovery1.TextBoxStyle.ForeColor = System.Drawing.Color.White
    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">
    <asp:passwordrecovery id="PasswordRecovery1" runat="server" 
        onuserlookuperror="PasswordRecovery1_UserLookupError">
        <textboxstyle backcolor="#C0FFC0"></textboxstyle>
    </asp:passwordrecovery>

</form>
</body>
</html>

注解

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

常见设置包括自定义背景色、文本颜色和字体属性。

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

以下 PasswordRecovery 属性由 TextBoxStyle 设置重写:

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

适用于

另请参阅