473,378 Members | 1,133 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,378 software developers and data experts.

ASPX form submites twice with ENTER key

I have a page with one form. I have one textbox in the page. I call a
client-side function on the OnKeyUp event of the textbox. This function
looks at the keycode of the keyup event on the textbox and checks for
13 which is the keycode for enter key. If I detect this keycode then I
do 2 things
(1) Set a hidden variable
(2) submit the form

I have noticed that the page is posted twice this way. But If I use a
button instead of detecting the enter key and submits the page that way
then the page is only posted once.

Please help.

Thanks.

Feb 16 '06 #1
3 2223
see if this explains your problem

http://www.allasp.net/enterkey.aspx

--
Regards

John Timney
Microsoft MVP

"tanya" <am****@gmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
I have a page with one form. I have one textbox in the page. I call a
client-side function on the OnKeyUp event of the textbox. This function
looks at the keycode of the keyup event on the textbox and checks for
13 which is the keycode for enter key. If I detect this keycode then I
do 2 things
(1) Set a hidden variable
(2) submit the form

I have noticed that the page is posted twice this way. But If I use a
button instead of detecting the enter key and submits the page that way
then the page is only posted once.

Please help.

Thanks.

Feb 16 '06 #2
DWS
Tanya,
Check your button properties. Buttons default to usesubmitbehavior=true so
there's your second submit. Set your button like this <asp:button
usesubmitbehavior="false"....></asp:button>

Good Luck
DWS

John Timney please review button behavior in the msdn library.

"tanya" wrote:
I have a page with one form. I have one textbox in the page. I call a
client-side function on the OnKeyUp event of the textbox. This function
looks at the keycode of the keyup event on the textbox and checks for
13 which is the keycode for enter key. If I detect this keycode then I
do 2 things
(1) Set a hidden variable
(2) submit the form

I have noticed that the page is posted twice this way. But If I use a
button instead of detecting the enter key and submits the page that way
then the page is only posted once.

Please help.

Thanks.

Feb 17 '06 #3
The link I provided explains the enter keys behaviour in different browsers
to help Tanya determine how using the enter key can affect submissions via
javascript and provides a working example of capturing and using the keycode
13 and ensuring that a certain button event if used is actioned, as opposed
to a different button/submit event pair bubbling postback events and causing
problems. Even the choice of button type can have an impact when your
capturing the keypress events when used in different browsers. Deactivating
autosubmit may indeed solve Tanya's immediate problem, it doesn't however
help her understand a connected range of problems she might expect when
capturing clientside keypress and how to work around them.

I dont think I need to review MSDN's behaviour on buttons - but thanks for
your enlightening suggestion.

Regards

John Timney
Microsoft MVP

"DWS" <DW*@discussions.microsoft.com> wrote in message
news:01**********************************@microsof t.com...
Tanya,
Check your button properties. Buttons default to usesubmitbehavior=true
so
there's your second submit. Set your button like this <asp:button
usesubmitbehavior="false"....></asp:button>

Good Luck
DWS

John Timney please review button behavior in the msdn library.

"tanya" wrote:
I have a page with one form. I have one textbox in the page. I call a
client-side function on the OnKeyUp event of the textbox. This function
looks at the keycode of the keyup event on the textbox and checks for
13 which is the keycode for enter key. If I detect this keycode then I
do 2 things
(1) Set a hidden variable
(2) submit the form

I have noticed that the page is posted twice this way. But If I use a
button instead of detecting the enter key and submits the page that way
then the page is only posted once.

Please help.

Thanks.


Feb 17 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Megha Vishwanath | last post by:
Hi, I have a struts form <html:form> in which although the focus rests on the submit button, hitting the enter key does not submit the form. I tried capturing the Enter key event and followed...
5
by: Tyler Style | last post by:
Hullo - looking for a little advice here. I have a form on a page in one domain submitting to a cgi in another domain. Weirdly, on some Windows XP systems, a form on the page fails to submit/post...
8
by: MNQ | last post by:
Hello All Im trying to relearn ANSI C. I have written some code but cannot understand why it is not do what i think it should. It prints the error message and the menu twice but i cant...
1
by: Lewis | last post by:
Hi, Im having a problem with an aspx page that I'm building (and rather urgently needing to complete!). Situation is this... Im transforming some XML using an XSLT which builds an HTML form...
13
by: ricky.agrawal | last post by:
I'm really not sure how to go about this in Access. What I've created is a table for each location. Those tables are identical in format but different in information. The tables are named after...
6
by: Brian Blair | last post by:
I have created a input form that enters a number in a talble. If I open the form again it enters a new record instead of editing the existing record. It seems like it should be very basic but I...
0
by: josephkorn | last post by:
Hi all. I have a problem in my website in trying to prevent a user from double submitting the form. I am calling a subroutine from my page_load event that passes in the commandbutton that I want...
5
by: dpimatrix | last post by:
Need to know if there is a sample code out there that I could use for this one Customer Interaction with the application 1.1 Registering with the system Customer provides their credit card number...
4
by: AdamOnAccess | last post by:
Here's a strange situation: I'm building an application that contains a One-To-Many relationship, and the application has a main form with a sub form to maintain the relationship for data entry. ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.