PasswordRecovery.OnUserLookupError(EventArgs) Metodo

Definizione

Genera l'evento UserLookupError.

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

Parametri

e
EventArgs

Oggetto EventArgs che contiene i dati dell'evento.

Esempio

Nell'esempio di codice seguente viene definito un controllo personalizzato PasswordRecovery che esegue OnUserLookupError l'override del metodo per modificare la UserNameTitleText proprietà se l'utente immette una risposta errata alla domanda di conferma della password.

<%@ 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>

Commenti

Il OnUserLookupError metodo viene chiamato quando il provider di appartenenza non riesce a trovare il nome utente immesso nella schermata iniziale. L'implementazione predefinita genera l'evento UserLookupError .

Quando viene generato un evento, il gestore dell'evento viene richiamato tramite un delegato. Per altre informazioni, vedere la gestione e generazione di eventi.

Il metodo OnUserLookupError consente inoltre alle classi derivate di gestire l'evento senza associare un delegato. È la tecnica consigliata per la gestione dell'evento in una classe derivata.

Note per gli eredi

Quando si esegue l'override di OnUserLookupError(EventArgs) in una classe derivata, verificare di chiamare il metodo OnUserLookupError(EventArgs) della classe di base in modo che i delegati registrati ricevano l'evento.

Si applica a

Vedi anche