Solved

Recognize Enter Key Pressed from any Form Field

Posted on 2004-09-08
7
281 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
This video discusses moving either the default database or any database to a new volume.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

708 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

16 Experts available now in Live!

Get 1:1 Help Now