Hi fellow programmers,
How do i login without clicking the login button after pressing the enter key on the keyboard in asp.net. after entering login details?
scenario: a user enters username and password,after entering password when he/she presses enter on the the keyboard, he/she must be logged in without physically clicking the login button.
Loading


Sam HobbsRank #108 · 20.5K reputationPosted Sep 23, 2011, 1:23 PM EDT
Andile Choko52 reputationPosted Sep 23, 2011, 1:58 PM EDT
Sam HobbsRank #108 · 20.5K reputationPosted Sep 23, 2011, 3:41 PM EDT
event.srcElement.focus();// This might not be necessary
switch (event.keyCode) {
case 13:
// do the same as is done in the OnClick of the button
break;
}
}
Note that you can use an if statement instead of a switch statement but if you want to check for other keys then the switch statement would be better.
Satyapriya NayakRank #47 · 31.5K reputationPosted Sep 23, 2011, 10:00 PM EDT
@Sam has explained it beautifully.
Also
Refer the below link
http://www.beansoftware.com/ASP.NET-Tutorials/Accept-Enter-Key.aspx
Thanks
If this post helps you mark it as answer