PasswordRecovery.OnAnswerLookupError(EventArgs) Méthode

Définition

Déclenche l’événement AnswerLookupError.

protected:
 virtual void OnAnswerLookupError(EventArgs ^ e);
protected virtual void OnAnswerLookupError (EventArgs e);
abstract member OnAnswerLookupError : EventArgs -> unit
override this.OnAnswerLookupError : EventArgs -> unit
Protected Overridable Sub OnAnswerLookupError (e As EventArgs)

Paramètres

e
EventArgs

EventArgs qui contient les données d’événement.

Exemples

L’exemple de code suivant crée un contrôle personnalisé PasswordRecovery qui remplace la OnAnswerLookupError méthode pour modifier la QuestionTitleText propriété si l’utilisateur entre une réponse incorrecte à la question de confirmation de mot de passe.

<%@ 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">
    class CustomPasswordRecovery : PasswordRecovery
    {
        override protected void OnAnswerLookupError(EventArgs e)
        {
            QuestionTitleText = "Try again";
            TitleTextStyle.ForeColor = System.Drawing.Color.Red;
            base.OnAnswerLookupError(e);
        }
    }
    
        // Add the custom password recovery control to the page.
        void Page_Init(object sender, EventArgs e)
        {
            CustomPasswordRecovery passwordRecoveryControl = new CustomPasswordRecovery();
        
            passwordRecoveryControl.ID = "passwordRecoveryControl";
        
            PlaceHolder1.Controls.Add(passwordRecoveryControl);
        
        }
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
<form id="form1" runat="server">
    <p>
        <asp:placeholder id="PlaceHolder1" runat="server"></asp:placeholder>&nbsp;</p>

</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">
    Class CustomPasswordRecovery
        Inherits PasswordRecovery
        
        Overloads Sub OnAnswerLookupError(ByVal e As EventArgs)
            QuestionTitleText = "Try again"
            TitleTextStyle.ForeColor = System.Drawing.Color.Red
            MyBase.OnAnswerLookupError(e)
        End Sub
    End Class

    ' Add the custom password recovery control to the page.
    Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs)
        Dim passwordRecoveryControl As New CustomPasswordRecovery
        
        passwordRecoveryControl.ID = "passwordRecoveryControl"
        
        PlaceHolder1.Controls.Add(passwordRecoveryControl)
        
    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">
    <p>
        <asp:placeholder id="PlaceHolder1" runat="server"></asp:placeholder>&nbsp;</p>

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

Remarques

La OnAnswerLookupError méthode est appelée lorsque la réponse de l’utilisateur à la question de confirmation de récupération de mot de passe ne correspond pas à la réponse stockée dans le magasin de données du site Web. L’implémentation par défaut déclenche l’événement AnswerLookupError .

Le déclenchement d'un événement appelle le gestionnaire des événements par l'intermédiaire d'un délégué. Pour plus d’informations, consultez gestion et déclenchement d’événements.

La méthode OnAnswerLookupError permet également aux classes dérivées de gérer l'événement sans y attacher de délégué. Il s'agit de la méthode recommandée pour gérer l'événement dans une classe dérivée.

Notes pour les héritiers

Lors de la substitution de OnAnswerLookupError(EventArgs) dans une classe dérivée, veillez à appeler la méthode OnAnswerLookupError(EventArgs) de la classe de base de manière à ce que les délégués inscrits reçoivent l'événement.

S’applique à

Voir aussi