Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Recognize Enter Key Pressed from any Form Field

Posted on 2004-09-08
7
Medium Priority
?
289 Views
Last Modified: 2008-01-12
I have a form with lots of textboxes and listboxes etc.

What i want is that whenever the user presses the enter key,be it from any of the form fields,it should recognize it and invoke the insert button click event which inserts the form data into a database.

0
Comment
Question by:ankuratvb
  • 4
  • 2
7 Comments
 
LVL 17

Expert Comment

by:AerosSaga
ID: 12006695
Here is a good tutorial on how to accomplish this:
http://www.allasp.net/enterkey.aspx

Regards,

Aeros
0
 
LVL 17

Accepted Solution

by:
AerosSaga earned 1000 total points
ID: 12006748
another work around:
This has got to be the wierdest fix I've ever seen, but it works. I was completely puzzled as to why my search button would -not- work when I entered data and hit enter. It would just not do anything. Then I read this article on Matt Berther's blog:

For the last few hours, I've been trying to figure out why my event handler is not being hooked up when I hit the ENTER key to submit my ASP.NET form.

As it turns out, this is a bug with ASP.NET. If you're not aware of this, the work around is to insert an invisible *HTML* textbox (an asp:TextBox wont work).

Add this line somewhere on the page:
<input type="text" style="display:none">
, and all will work as expected.
0
 
LVL 17

Expert Comment

by:AerosSaga
ID: 12006772
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 9

Author Comment

by:ankuratvb
ID: 12008191
I'll be going thru the links and trying the fix as well.

In my case,while entering data,only the insert and the cancel buttons are enabled.On pressing enter,the focus goes to the cancel button and its click event generated.

0
 
LVL 9

Author Comment

by:ankuratvb
ID: 12014527
Hi,

After using the text box fix,what happens is that on pressing enter,control goes to the next(in sequence according to the html) submit button(asp:Button's are submit buttons) on the page.

SO i just had to change the html so that the insert button happens to be the next button in the html.

And it works fine now.
Thanx
0
 
LVL 17

Expert Comment

by:AerosSaga
ID: 12015314
right on
0
 
LVL 1

Expert Comment

by:dingir
ID: 20646041
this problem appear on forms where there are only one input element
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

782 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question