473,418 Members | 2,368 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,418 software developers and data experts.

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 2910
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Simon Wigzell | last post by:
Is there a way to prevent a form submitting when you press enter on a text field? Some people press enter when they finish typing in a text field out of habit I guess unconcsciously thinking it...
3
by: w. jORDAN | last post by:
Hello all, It's known to how to make user press enter in an asp:textbox and the form is submited by adding an attribute to the textbox with an onkeydown jscript eventhandler. For example,...
6
by: guoqi zheng | last post by:
In a regular html form, when user press "enter" key, the form will be submitted. However, in ASP.NET web form, a form will only be submitted (post back) when a special button is clicked. Many...
11
by: Sven | last post by:
I want this: when I press commandbutton1, then the program should send the keystroke "enter" to text1.text... how can I do this?
3
by: aryayudhi | last post by:
I have a html page that has javascript that works perfectly in IE, but not in Firefox. The use of this javascript to change "Tab" to "Enter" Button. When we press Tab, it is like when we press Enter...
0
pgmrkim
by: pgmrkim | last post by:
Thanks for the great code example. I've been trying to do a similar client-side script for a few days now.
3
by: Zytan | last post by:
I can handle DoubleClick on a ListBox to respond, not when the selection changes, but when you double click one to invoke an action. This is the same as using the keys to move the selection, then...
2
by: Magnus Warker | last post by:
Hi, can I associate the pressing of "enter" with one of the forms submit buttons? Thanks Magnus
1
by: daonho | last post by:
I tried to use javascript to trigger up the button click function when user press enter key from the textbox. This function work fine with a single button click such has login page. However, if the...
2
by: donomuch | last post by:
I have a form where user enters a password text, then has to click the Submit Password button. How do I add the option to press Enter key to call the same function 'goForit'? I read similar...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.