Export (0) Print
Expand All

Login.LoginError Event

Note: This event is new in the .NET Framework version 2.0.

Occurs when a login error is detected.

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

public event EventHandler LoginError
/** @event */
public void add_LoginError (EventHandler value)

/** @event */
public void remove_LoginError (EventHandler value)

JScript supports the use of events, but not the declaration of new ones.

The LoginError event is raised when the credentials entered by the user are invalid. You can use the LoginError event to redirect the user to a custom error page, to offer additional help, or to log failed login attempts.

For more information about handling events, see Consuming Events.

The following code example uses the LoginError event to display Help links to the user when a login attempt fails.

<%@ 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>
    <BODY>
        <FORM runat="server">
            <asp:Login id="Login1" runat="server" 
                CreateUserUrl=createUser.aspx 
                HelpPageUrl=loginHelp.aspx 
                PasswordRecoveryUrl=getPass.aspx 
                OnLoginError=OnLoginError>
            </asp:Login>
        </FORM>
    </BODY>
</HTML>

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0

Community Additions

ADD
Show:
© 2015 Microsoft