AnswerLookupError Event

PasswordRecovery.AnswerLookupError Event

 

Occurs when the user enters an incorrect answer to the password recovery confirmation question.

Namespace:   System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

public event EventHandler AnswerLookupError

The AnswerLookupError event is raised when the answer to the password recovery question is not validated by the membership provider defined in the MembershipProvider property.

If the membership provider does not support password recovery question and answer, the AnswerLookupError event is never raised.

For more information about handling events, see NIB: Consuming Events.

The following code example uses the AnswerLookupError event to reset the QuestionTitleText property if the user enters an invalid answer to the password confirmation question.

<%@ 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.UserNameTitleText = "Try again";
    PasswordRecovery1.TitleTextStyle.ForeColor = System.Drawing.Color.Red;
  }

  void PasswordRecovery1_AnswerLookupError(object sender, EventArgs e)
  {
    PasswordRecovery1.QuestionTitleText = "Try again";
    PasswordRecovery1.TitleTextStyle.ForeColor = 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">
  <asp:passwordrecovery id="PasswordRecovery1" runat="server" 
    questiontitletext="Password Confirmation Question"
    usernametitletext="Get a new password" OnUserLookupError="PasswordRecovery1_UserLookupError" OnAnswerLookupError="PasswordRecovery1_AnswerLookupError">
    <titletextstyle 
      font-names="Arial" 
      font-bold="True" 
      forecolor="White" 
      backcolor="Gray">
    </titletextstyle>
  </asp:passwordrecovery>

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

.NET Framework
Available since 2.0
Return to top
Show:
© 2016 Microsoft