Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Key press "Enter" does not submit the form

Reply
Thread Tools

Key press "Enter" does not submit the form

 
 
Andrea Williams
Guest
Posts: n/a
 
      05-24-2004
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


 
Reply With Quote
 
 
 
 
Steve C. Orr [MVP, MCSD]
Guest
Posts: n/a
 
      05-24-2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
STRUTS- <html:submit> does not submit on pressing Enter key Megha Vishwanath Java 2 10-02-2009 12:52 PM
How to know when an enter key press is used to select an item in thebrowser's context dropdown and not to submit a form? Daniel Smedegaard Buus Javascript 4 08-07-2008 04:18 PM
IE 5+ default form submit on Enter Key Press WJ HTML 1 01-19-2005 08:27 AM
Form submit - hitting enter does not trigger Submit button ASP General 2 10-25-2004 03:37 PM
STRUTS-<html:submit> -Hitting enter key does not submit the form Megha Vishwanath Javascript 3 07-20-2004 05:45 AM



Advertisments