Solved

Recognize Enter Key Pressed from any Form Field

Posted on 2004-09-08
7
282 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 250 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SharePoint 2013 Business Data Connectivity Services questions 7 33
Multiple file Upload asp.net 2 36
SQL best practice question 3 36
Run time Error 4 34
One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.

948 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now