469,945 Members | 1,910 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,945 developers. It's quick & easy.

Key press "Enter" does not submit the form

I've created a simple search form and a submit button. On click of the
button, I have code-behind that runs and fills a datagrid. However, it the
person is focused on one of the other controls and presses the "Enter"
button, my submit button event code doesn't fire so my datagrid is either
empty, or it shows a lot of blank rows. It looks like the submit happened,
but since my code to fill the datagrid is in the submit_click method, it's
not executed.

So how can I get the "Enter" button to execute the event method for the
submit button? Is there a way to handle the key press event and make it run
the submit_click method?

Thanks,
Andrea
Nov 18 '05 #1
1 2746
You can intercept the client side enter keypress event of the text box and
then do what you want using javascript code.
Here's a good example:
http://www.kamp-hansen.dk/pages/show...d=21&menuid=18

You could also try using this free control.
http://www.metabuilders.com/tools/DefaultButtons.aspx

And here's a couple good articles on the subject:
http://www.allasp.net/enterkey.aspx
http://www.aspnetpro.com/features/20...200406so_f.asp

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"Andrea Williams" <an*******@hotmail.IHATESpam.com> wrote in message
news:uV**************@TK2MSFTNGP12.phx.gbl...
I've created a simple search form and a submit button. On click of the
button, I have code-behind that runs and fills a datagrid. However, it the person is focused on one of the other controls and presses the "Enter"
button, my submit button event code doesn't fire so my datagrid is either
empty, or it shows a lot of blank rows. It looks like the submit happened, but since my code to fill the datagrid is in the submit_click method, it's
not executed.

So how can I get the "Enter" button to execute the event method for the
submit button? Is there a way to handle the key press event and make it run the submit_click method?

Thanks,
Andrea

Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by w. jORDAN | last post: by
6 posts views Thread by guoqi zheng | last post: by
11 posts views Thread by Sven | last post: by
2 posts views Thread by Magnus Warker | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.