Possible Duplicate:
Submit Login control button when I hit Enter
I have a Login.aspx page with:
<asp:Login ID="MainLogin" runat="server" onloggingin="MainLogin_LoggingIn"></asp:Login>
Code-behind:
protected void MainLogin_LoggingIn(object sender, LoginCancelEventArgs e)
{
SqlConnection myConnection = new SqlConnection(DBConnection.GetConnectionString());
SqlCommand myCommand = new SqlCommand("SELECT * FROM Users WHERE login=@login and pass=@pass", myConnection);
myCommand.Parameters.AddWithValue("login", MainLogin.UserName);
myCommand.Parameters.AddWithValue("pass", MainLogin.Password);
myCommand.Connection.Open();
SqlDataReader Reader = myCommand.ExecuteReader();
while (Reader.Read())
{
Session["curUserRole"] = Reader["role"].ToString();
Session["curUserLogin"] = MainLogin.UserName;
FormsAuthentication.RedirectFromLoginPage(MainLogin.UserName, MainLogin.RememberMeSet);
return;
}
//Reader.Close();
//myCommand.Connection.Close();
//myConnection.Close();
}
A user types his login and password, and then presses the "login" button of the component to login. When the user types his login and password and then presses ENTER on his keyboard, the page login.aspx reloads. How to fix that? I need that pressing ENTER on keyboard has the same behavior as pressing the login button on the component.