Login.FailureText 属性

定义

获取或设置当登录尝试失败时显示的文本。

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

属性值

String

当登录尝试失败时向用户显示的文本。 默认值为“您的登录尝试失败。 请重试。”

示例

下面的代码示例将 FailureText 属性设置为“登录时出错。 请重试”。

<%@ Page Language="C#" AutoEventWireup="False"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
</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:Login id="Login1" runat="server" FailureText="There was an error while logging you in. Please try again.">
                <FailureTextStyle ForeColor="White" BackColor="Red"></FailureTextStyle>
            </asp:Login>

        </form>
    </body>
</html>
<%@ Page Language="VB" AutoEventWireup="False"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
</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:Login id="Login1" runat="server" FailureText="There was an error while logging you in. Please try again.">
                <FailureTextStyle ForeColor="White" BackColor="Red"></FailureTextStyle>
            </asp:Login>

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

注解

FailureText 属性指定登录尝试失败时显示的字符串。

如果为 Login 控件定义模板,则可以指示模板上使用控件显示 FailureText 属性 Literal 的位置,并为该控件提供 ID“FailureText”。 使用模板时,该 FailureTextStyle 属性不会应用于属性中指定的 FailureText 文本。

属性的默认文本基于服务器的当前区域设置进行本地化。

备注

出于安全原因,登录失败文本不应包含失败的特定原因。 例如,错误消息(如“密码对用户 <username>无效”)向系统上的用户的潜在攻击者 <username> 显示。 有关详细信息,请参阅如何:显示保险箱错误消息

设置时,此属性的值可以使用设计器工具自动保存到资源文件中。 有关详细信息,请参阅LocalizableAttribute全球化和本地化

适用于

另请参阅