enter key button click asp net





One of the common requests in ASP.NET is to submit a form when visitor hits an Enter key. That could be a case if, for example you want to make Login Screen. It is expected that user just hit enter when he insert a user name and password instead to of forcing him to use a mouse to click login button. The enter key has a keyCode of 13 so with a simple if statement we can test the key, if it is indeed the enter key then we can manually click the button we want.DataFormatString CSharp ASP.NET (1) Rich wrote: GREAT POST! In ASP.Net 1.x days, we need can do this by writting a custom javascript code which can identify the enter key press and submit the form.Now, hitting enter key from inside the panel(Panel1) control will fire the click event of the button(btnSave). When the Enter key is pressed within an ASP.NET Web Form that has multiple single-line textboxes, the form will submit and the Button Web control that appears first in the HTML pages markup will have its Click event fired. I believe (and stand to be corrected), but if you have a form, with an input button of type submit, then when you hit enter, itll fire that button click. Then add this javascript to evaluate the key press, and if it is "enter," click the right button.