473,656 Members | 2,756 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 3966
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.ke yCode : e.keyCode;
alert(val);
}
</script>
<input type="text" onkeypress="han dle_keypress(ev ent);"/>
[/HTML]
kind regards
Dec 11 '07 #5

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

Similar topics

1
6393
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 button on the form. When the user hits enter the button is clicked. I have a second page mycsepp.aspx which has an asp button and a link button. When I hit enter neither of the button click events are triggered. If I tab to one of them and
0
1862
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 write something in text box and press Enter I invoke that button method ?!?! But this is not button I want to be default. I set tab orders and nothing always that button becomes default when I am on some text box on web form. How can I set default...
2
8093
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 logic I have for the button. In other words, I would like to have a default button for the form, is this making sense? I thought I saw on Fritz Onion's MSDN webcasts there is a way to assign a default button to a form/page, is this in fact...
5
5419
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
4811
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 default. It's not there now. I found in the help index an isdefault property and tried to set it in code but it doesn't show up in the list when I type button1.isdef
1
2111
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 to be the default when filling out a different art of the form. I can't seem to find a way of stopping the first button on the form begin selected. I know there is a way to do this in ASP.NET 2.0 but I can't seem to find one in ASP.NET 1.0
3
1564
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 context, the panel of a form which contains various buttons , are shown or hides. Now at design time i set the default button property to one of button. But when the form object is created in different context and set visibilty of default
15
12531
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 property. Where is it? Or mabye change the other thing,No?Thanks ! Simon
2
3498
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 value set to datasheet. When I click on the button that goes to the supplier form from the purchase form, the form changes into a single form view and not the datasheet view set for it.
4
2980
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 week. The main form has a combo box that must have a value selected before anything else can happen. Once that value is selected, the 7 subforms are enabled, and also one of the fields is populated with the value from the main form. These subforms also...
0
8382
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8816
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8498
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8600
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7311
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6162
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4150
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4300
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1930
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.