Login.LoginError Événement

Définition

Se produit lorsqu'une erreur de connexion est détectée.

public:
 event EventHandler ^ LoginError;
public event EventHandler LoginError;
member this.LoginError : EventHandler 
Public Custom Event LoginError As EventHandler 

Type d'événement

Exemples

L’exemple de code suivant utilise l’événement LoginError pour afficher des liens d’aide vers l’utilisateur lorsqu’une tentative de connexion échoue.

<%@ 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 OnLoginError(object sender, EventArgs e)
{
    Login1.HelpPageText = "Help with logging in...";
    Login1.CreateUserText = "Create a new user...";
    Login1.PasswordRecoveryText = "Forgot your password?";
}
</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" 
                CreateUserUrl="createUser.aspx" 
                HelpPageUrl="loginHelp.aspx" 
                PasswordRecoveryUrl="getPass.aspx" 
                OnLoginError="OnLoginError">
            </asp:Login>
        </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">
Sub OnLoginError(ByVal sender As Object, ByVal e As EventArgs)
    Login1.HelpPageText = "Help with logging in..."
    Login1.CreateUserText = "Create a new user..."
    Login1.PasswordRecoveryText = "Forgot your password?"
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">
            <asp:Login id="Login1" runat="server" 
                CreateUserUrl="createUser.aspx" 
                HelpPageUrl="loginHelp.aspx" 
                PasswordRecoveryUrl="getPass.aspx" 
                OnLoginError="OnLoginError">
            </asp:Login>
        </form>
    </body>
</html>

Remarques

L’événement LoginError est déclenché lorsque les informations d’identification entrées par l’utilisateur ne sont pas valides. Vous pouvez utiliser l’événement LoginError pour rediriger l’utilisateur vers une page d’erreur personnalisée, pour offrir une aide supplémentaire ou pour enregistrer les tentatives de connexion ayant échoué.

Pour plus d’informations sur la façon de gérer les événements, consultez gestion et déclenchement d’événements.

S’applique à

Voir aussi