Recently need to press the button search function, instead support press ENTER enter key, search.
Implementation by pressing ENTER, the Click event is still relatively simple.
Press ENTER to search for a user
$ (window). KeyDown (function (event) {
Alert ("You pressed the key");
if (Event.keycode = = 13) {
Alert ("You pressed enter");
var Source = $ ("#<%=button1.clientid%>"). Click ();
document.getElementById ("<%=button1.clientid%>"). Click ();
return false;
}
});
The above code will be able to implement this function.
But when implemented, found to press ENTER multiple times to search for results, and then led to say that the form form by default press ENTER to submit the form, so very depressed, because the master page.
Can not run out of the Master Page form form, how to do, and finally found that after the Click event returned false, prevent form form submission, and finally solve the problem perfectly.
How to Prevent carriage return (enter) key to submit a form, in fact very simple, just a word. Onkeydown= "if (event.keycode==13) return false;" Just write this sentence in the from tag.
Press ENTER to perform a click or search problem