473,503 Members | 1,625 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Default button in web form

45 New Member
Is there a way to set a button as default in a web form? Current issue is that a return pressed while in the form sends a form submit. This is fine, except I do not want to send a full postback. I am trying to override the postback and use an AJAX call instead. I tried capturing the keypress event in the text box, but it still is requesting a full page submit back to the server (even though I am using an input tag with a button type).

Thanks,
Leo
Dec 10 '07 #1
4 3957
drhowarddrfine
7,435 Recognized Expert Expert
Not with html/css. I'll send this to javascript board.
Dec 10 '07 #2
gits
5,390 Recognized Expert Moderator Expert
hi ...

please post the code you already have so that we may have a closer look at your problem ...

kind regards
Dec 10 '07 #3
Leo Smith
45 New Member
I have a simple question. I actually fixed the problem only because the callback for the AJAX call failed due to the event was not fired from the button click. I then took the failure and ensured that it did the click call on the button, thus sending the proper message.

The question is which event fires when you hit return in an input element (type text)? It doesn't seem to be the onsubmit event for the form or a onkeypress event on the control (neither of these fired when I was trying to deal with the problem). It also doesn't fire the onclick event for a button that even if it is the only button on the page.

By the way, the main browser that is causing the problem is Firefox (Windows and MAC versions, all point releases), with IE 7.0 sometimes failing. The error does return to the AJAX failed function.


Thanks,
Leo
Dec 11 '07 #4
gits
5,390 Recognized Expert Moderator Expert
hi ...

you may use the keypress-event:

[HTML]<script>
function handle_keypress(e) {
var val = typeof window.event != 'undefined' ? window.event.keyCode : e.keyCode;
alert(val);
}
</script>
<input type="text" onkeypress="handle_keypress(event);"/>
[/HTML]
kind regards
Dec 11 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
6381
by: Billy Jacobs | last post by:
Is there a way to make a button on a web form the default button so that when the user hits the enter button the code for that button executes? I have a web page Login.aspx where I have only 1...
0
1853
by: Shixx | last post by:
Hello, I have problem in my web application and my web form. I have 5-6 buttons (web controls) and when I have focus on some text box, always one button becomes default and got focus, and after I...
2
8085
by: Flip | last post by:
On my current form, when I hit the enter key in a texbox, the form appears to resubmit itself, but it's not actually doing a submit (or so I think?). I would like to have the enter button fire the...
5
5405
by: Wonder | last post by:
How can I create or use the msgobx to show a message without a default button. The user has explicity to click on the button, so the msgbox closes it. Thanks,
10
4797
by: cj | last post by:
Here's an easy one, I hope. How do I make button1, which I put on this form from the toolbox, the default button on the form? I thought it used to be a property in the properties window called...
1
2101
by: andyrich_1 | last post by:
I have a simple form that has two submit buttons on it. The problem I have is that I want one button to be the default button when the user is filling out one section of the form and another button...
3
1547
by: Anil Kumar Sharma | last post by:
Hello, I am working on C# using vs.net 2003. I have faced two interesting problems. 1. Dynamically setting Default Button: I created a form and used it in various contexts. On basis of the...
15
12514
by: simonoficina | last post by:
Hello all! I am a vb.net beginner in Spain. When I use VB6 ,the button object has a property called "default" that can set this button like press "ENTER" key. But in the VB.net I can't find this...
2
3488
by: Dave | last post by:
I have a simple little purchase form, on it is a button that takes the user to a suppliers form . The purchase form has a default view set to single form, and the supplier form has a default...
4
2967
by: Whasigga | last post by:
Hi I've created a form that has 7 subforms. It is the same subform, bound to a table, just repeated. This form represents a week, and each subform is used to enter in data for each day of the...
0
7188
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
7063
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
7313
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...
1
6970
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7441
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
4663
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...
0
3156
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3146
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
720
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.