I have many fields in the page and the last field is a dropdown with list of values. When I select an item in a dropdown and press Enter, it doesn't do the "Ok". Instead I have to manually click on Ok to Submit. How can I do by pressing Enter on my Keyboard rather than Clicking on "Ok" button after selecting the value from dropdown list. I have set the SubmitBehavior to true.
+3
A:
Try the solution here: ASP.NET 2.0 - Enter Key - Default Submit Button.
Chris Thompson
2009-11-09 18:51:07
You answer talks about Win forms, the OP is asking about Web forms. I won't vote, though.
Moayad Mardini
2009-11-09 18:53:45
Thanks, I misread that site, the concept is the same, I'll find a new link
Chris Thompson
2009-11-09 18:57:43
Good link. +1..
Moayad Mardini
2009-11-09 19:06:02
Made up for my bone head :) good edit, thanks!
Chris Thompson
2009-11-09 19:08:27
You're more than welcome.
Moayad Mardini
2009-11-09 19:10:22
great link, thanks!
adrianos
2009-11-19 13:20:50
+1
A:
Assuming you're talking about a web form:
I'm no ASP.NET guru, but the default behavior of an HTML form is to submit in this case. Common causes for this are the HTML form fields not being contained within the form element, or the submit button having a nonstandard javascript function fire instead of submitting proper.
I realize that's not an answer, but I hope it might help.
Adam Bard
2009-11-09 18:51:17
+1
A:
using jquery you can do something like this
$("#fieldName").keypress(function(event)
{
if (event.keyCode == 13)
{
return true;
}
else
{
return false;
}
});
See more here: http://docs.jquery.com/Events/keypress
Andrew Siemer
2009-11-09 18:54:50