I have an asp.net login control. It works fine but you have to press the actual button login in order to login. I would like to do it if the user presses enter as well. how can this be done?
Asked
Active
Viewed 1,787 times
0
-
possible duplicate of http://stackoverflow.com/questions/3237377/allow-enter-key-to-login-in-asp-net or http://stackoverflow.com/questions/201776/submit-login-control-button-when-i-hit-enter – Bruno Silva Jan 30 '12 at 02:32
3 Answers
0
Not sure if this is what you're looking for but check out the AccessKey property
Greg
- 8,574
- 21
- 67
- 109
0
There are some workaround on this. Have a look at code snippet. (No need to add panel control)
protected void Page_Load(object sender, EventArgs e)
{
TextBox Password = (TextBox)Login1.FindControl("Password");
Button ButtonLogin = (Button)Login1.FindControl("LoginButton");
Password.Attributes.Add("onKeyPress", "javascript:if (event.keyCode == 13) __doPostBack('" + ButtonLogin.UniqueID + "','')");
}
KV Prajapati
- 93,659
- 19
- 148
- 186