Login.LoginError Event
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Occurs when a login error is detected.
public:
event EventHandler ^ LoginError;
public event EventHandler LoginError;
member this.LoginError : EventHandler
Public Custom Event LoginError As EventHandler
Event Type
Examples
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 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>
Remarks
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 how to handle events, see Handling and Raising Events.