For some reason, when I am in the password text box, when I press enter, it simply clears both fields. Doesn't validate, doesn't login, just clears the fields. What is going on here?

Codebehind:

PrivateSub cmdLogin_ServerClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdLogin.ServerClick
If FormsAuthentication.Authenticate(txtUser.Text, txtPass.Text) Then
FormsAuthentication.RedirectFromLoginPage(txtUser.Text, chkPersist.Checked)
Else
lblStatus.Text = "Not Authenticated"
IfCInt(ViewState("Tries")) > 1 Then
Response.Redirect("Denied.aspx")
Else
' Otherwise, increment number of tries.
ViewState("Tries") = CInt(ViewState("Tries")) + 1
EndIf
EndIf
EndSub

And the aspx page is attached. Please help.

Slade

Attachments
<%@ Register TagPrefix="uc1" TagName="Header" Src="Header.ascx" %>
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="FacLogin.aspx.vb" Inherits="sladesfaculty.FacLogin"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
	<HEAD>
		<title>FacLogin</title>
		<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
		<meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
		<meta content="JavaScript" name="vs_defaultClientScript">
		<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
		<LINK href="FacStyles.css" type="text/css" rel="stylesheet">
	</HEAD>
	<body>
		<form id="Form1" method="post" runat="server">
			<table height="100%" cellSpacing="0" cellPadding="0" width="100%" border="0">
				<tr>
					<td width="100%"><uc1:header id="Header1" runat="server"></uc1:header></td>
				</tr>
				<tr>
					<td vAlign="middle" align="center" width="100%" height="100%">
						<table cellSpacing="0" cellPadding="0" border="0">
							<tr>
								<td colSpan="3"><asp:label id="lblStatus" runat="server" ForeColor="Red" Font-Size="X-Small"></asp:label></td>
							</tr>
							<tr>
								<td vAlign="top" rowSpan="3"><IMG src="Images/Login/lgnlt.gif"></td>
								<td vAlign="top" bgColor="#999999"><IMG src="Images/Login/lgntop.gif"></td>
								<td vAlign="top" rowSpan="3"><IMG src="Images/Login/lgnrt.gif"></td>
							<tr>
								<td height="126">
									<table height="100%" cellSpacing="0" cellPadding="0" width="100%" bgColor="#999999" border="0">
										<tr>
											<td><asp:label id="lblUser" runat="server" ForeColor="Black" Font-Size="X-Small" BackColor="Transparent">Username:</asp:label></td>
											<td align="right"><asp:textbox id="txtUser" runat="server" MaxLength="20" Font-Size="X-Small" BorderStyle="Inset"></asp:textbox></td>
										</tr>
										<tr>
											<td colSpan="2"><asp:requiredfieldvalidator id="RequiredFieldValidator1" runat="server" ErrorMessage="*Username Required" ControlToValidate="txtUser"
													Font-Size="X-Small"></asp:requiredfieldvalidator></td>
										</tr>
										<tr>
											<td><asp:label id="lblPass" runat="server" ForeColor="Black" Font-Size="X-Small" BackColor="Transparent">Password:</asp:label></td>
											<td align="right"><asp:textbox id="txtPass" runat="server" TextMode="Password" MaxLength="20" Font-Size="X-Small"
													BorderStyle="Inset"></asp:textbox></td>
										</tr>
										<tr>
											<td colSpan="2"><asp:requiredfieldvalidator id="RequiredFieldValidator2" runat="server" ErrorMessage="*Password Required" ControlToValidate="txtPass"
													Font-Size="X-Small"></asp:requiredfieldvalidator></td>
										</tr>
										<tr>
											<td colSpan="2"><asp:checkbox id="chkPersist" runat="server" Text="Remember Me?" ForeColor="Black" Font-Size="X-Small"
													BackColor="Transparent"></asp:checkbox></td>
										</tr>
									</table>
								</td>
							</tr>
							<tr>
								<td align="right" background="Images/Login/lgnbtm.gif" height="43"><input type="submit" value="Login" id="cmdLogin" runat="server"></td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<td>&nbsp;
						<asp:Label id="lblCopy" runat="server" Font-Size="X-Small"> SladesFaculty 2004</asp:Label></td>
				</tr>
			</table>
		</form>
	</body>
</HTML>

Is the viewstate enabled? Is the page properly posting back? Try putting in a Response.Write somewhere...

ok clicking on the actual button with the mouse WORKS, but when I hit enter and I'm in the password field, it just clears the form whats the deal? It should just login like when I click it, please help.


Thanks in advance,

Slade

As always tekmaven you were helpful, that control is awesome. Where do you find out about all of them?

As always tekmaven you were helpful, that control is awesome. Where do you find out about all of them?

Just about every employee that works on .NET at Microsoft has blogs. Just get a good RSS agregator, and check them all. With a little time each day (okay, maybe a lot), I guaruntee you will learn a lot.

And, the thanks for the kind words. Don't forget to share that thought with the member rating system ("reputation").. ;) .

Comments
Sorry buddy :P forgot it existed.
This article has been dead for over six months. Start a new discussion instead.