I stumbled across a little problem with an ASP.NET Web Application.
I got a couple buttons on my page that I want to access by pressing my Enter key (Depending on which TextBox is focused).
Googled helped me, I thought, but no.
This is what I found:
tbEmail.Attributes.Add("onkeydown", "if(event.which || event.keyCode){if ((event.which == 13) || (event.keyCode == 13)) {document.getElementById('" + btRegister.UniqueID + "').click();return false;}} else {return true}; ");
This does not seem to work, it still presses another button that I do not want to be pressed at this moment.
Any suggestions?
It looks like you’re using Web Forms.
You can wrap what you’re doing inside of a
Paneland set theDefaultButtonproperty inside of the panel.When the user has entered data in either
txtUserandtxtPassand then hit the Enter key, they will trigger the buttonbtLogin.