我在 asp.net 页面中有一个登录控件。在 MSDN 上,指定 FailureText 属性(如果未指定)默认为"您的登录尝试失败。请再试一次。
我需要在 Login1_LoggingIn 事件登录失败时输入自定义消息,以便当密码输入错误 4 次时,帐户被锁定,我在此事件上通知用户。
但是,在锁定时间到期后,我需要恢复为默认值"您的登录尝试失败。有没有办法将 FailureText 属性恢复到其默认状态?
问题是,如果我覆盖上述事件的 FailureText,它将在所有后续回发中保持这种状态。
谢谢
您应该能够挂接到Login1_LoginError事件并从那里更改消息,然后您可以决定每次发生故障时显示的内容,即
private void Login1_LoginError(object sender, EventArgs e)
{
failureCount++; //Retrieve this from Database or something
if (failureCount >= 4)
{
Login1.FailureText = "Account is locked";
}
else
{
Login1.FailureText = "Your login attempt has failed. Please try again";
}
}