473,670 Members | 2,499 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to set onclick for default button

RA
Hi

I have asp.net web app. When a user clicks the enter key when he is viewing
the aspx web form, it jumps to the starting web form. How can I handle the
user hitting the enter key and to redirect it to a default button. So lets
say that I have a button name - Submit - if the user clicks anywhere in the
form on the enter key I want it to default to a click on the 'Submit' button
which is an asp.net button.
Thanks,
Ron
Nov 17 '05 #1
4 4892
Do this in you r/javascript function hooked to any where
on textbox etc.

function abc()
{
if(window.event .keyCode == '13')
{
document.getEle mentById(yoursu bmitnuttonid).c lick
();
event.returnVal ue = false;
}
}

event.returnval ue is for avoiding beep sound.

Happy programming..
Ajay
-----Original Message-----
Hi

I have asp.net web app. When a user clicks the enter key when he is viewingthe aspx web form, it jumps to the starting web form. How can I handle theuser hitting the enter key and to redirect it to a default button. So letssay that I have a button name - Submit - if the user clicks anywhere in theform on the enter key I want it to default to a click on the 'Submit' buttonwhich is an asp.net button.
Thanks,
Ron
.

Nov 17 '05 #2
Do this in you r/javascript function hooked to any where
on textbox etc.

function abc()
{
if(window.event .keyCode == '13')
{
document.getEle mentById(yoursu bmitnuttonid).c lick
();
event.returnVal ue = false;
}
}

event.returnval ue is for avoiding beep sound.

Happy programming..
Ajay
-----Original Message-----
Hi

I have asp.net web app. When a user clicks the enter key when he is viewingthe aspx web form, it jumps to the starting web form. How can I handle theuser hitting the enter key and to redirect it to a default button. So letssay that I have a button name - Submit - if the user clicks anywhere in theform on the enter key I want it to default to a click on the 'Submit' buttonwhich is an asp.net button.
Thanks,
Ron
.

Nov 17 '05 #3
You can intercept the client side enter keypress event of the text box and
then click 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 good article on the subject:
http://www.allasp.net/enterkey.aspx

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
Hire top-notch developers at http://www.able-consulting.com

"RA" <ro****@hotmail .com> wrote in message
news:Oi******** *******@TK2MSFT NGP10.phx.gbl.. .
Hi

I have asp.net web app. When a user clicks the enter key when he is viewing the aspx web form, it jumps to the starting web form. How can I handle the
user hitting the enter key and to redirect it to a default button. So lets
say that I have a button name - Submit - if the user clicks anywhere in the form on the enter key I want it to default to a click on the 'Submit' button which is an asp.net button.
Thanks,
Ron

Nov 17 '05 #4
You can intercept the client side enter keypress event of the text box and
then click 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 good article on the subject:
http://www.allasp.net/enterkey.aspx

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
Hire top-notch developers at http://www.able-consulting.com

"RA" <ro****@hotmail .com> wrote in message
news:Oi******** *******@TK2MSFT NGP10.phx.gbl.. .
Hi

I have asp.net web app. When a user clicks the enter key when he is viewing the aspx web form, it jumps to the starting web form. How can I handle the
user hitting the enter key and to redirect it to a default button. So lets
say that I have a button name - Submit - if the user clicks anywhere in the form on the enter key I want it to default to a click on the 'Submit' button which is an asp.net button.
Thanks,
Ron

Nov 17 '05 #5

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

Similar topics

3
2804
by: Stefan Finzel | last post by:
Hi what's the right way to add ONCLICK to a form button using javascript? <HTML>... <INPUT ID="RESET" NAME="RESET" TYPE="RESET" VALUE=" Reset ">No onclick is used here <SCRIPT TYPE="text/javascript">...
10
1880
by: drawde83 | last post by:
Hi, I'm mocking up an interface in javascript for an HCI assignment. I want to be able to make the default onclick event for the buttons on my page to display an alert since the buttons won't work yet. Is there an easy way to do this? and it has to be as easy as giving each button their own onclick attribute otherwise I'll just do that.
2
3282
by: Sedef | last post by:
Hi, i'm trying to create a custom Button user control which will be derived from System.Web.UI.WebControls.Button. the normal server side Button class creates some client side javascript code for its onclick event. it's something like: <input type="submit" name="Button1" value="Button" onclick="if (typeof(Page_ClientValidate) == 'function') Page_ClientValidate(); " language="javascript" id="Button1" /> what i want to do is to be able to...
2
1845
by: Lenard Gunda | last post by:
Hi! I have an ASP.NET page with multiple TextBox fields and buttons. When I press the <enter> key in a TextBox, the page postbacks, and one of the buttons get fired (OnClick). Now certain TextBoxes trigger one particular button on the page (this is the first button on the page, so probably that's why that gets fired), while there is one TextBox, that seems to trigget another one. I have no idea what's the difference between the...
2
2073
by: moondaddy | last post by:
I have an asp.net 2.0 application and put a html button on a web page. I double clicked on the button and it crated the event handler for me and created the stub js function for it like this: <input id="btnQryFunctions" type="button" value="Query Functions" language="javascript" onclick="return btnQryFunctions_onclick()" /> and the function it created was: function btnQryFunctions_onclick() {
4
13551
by: sameergn | last post by:
Hi, I have an image in my HTML form which has onclick() handler. There is also a submit button and a text box. Whenever text box has focus and user presses enter, the onclick() event of image is fired with event.keyCode as undefined. I was expecting that the form would get submitted. I tried returning from onclick() handler if keyCode is null, but the
3
5833
by: Harry Haller | last post by:
I have a radio button group. When the page loads none of them are selected. OnClick selects ONE and clicking another one selects a different one - this is normal behavior. I want to modify it so that clicking on a radio which is already selected will deselect it so that none of the group are selected. I can get the required behavior with a double-click: ondblclick="this.checked=!(this.checked);"
5
11655
by: GiJeet | last post by:
Hello, I'm trying to figure this code out. <input type="submit" onclick="if(!confirm('Are you sure?') return false; "... /> I know that if you return false in an event like this onclick it prevents the default behavior of the event. So, in the onclick of a button the default behavior is to submit the form. Confirm returns the value 1 if the user clicks OK and the value 0 if
18
3940
by: navyjax2 | last post by:
What if your event handler has to be nonstatic?
0
8468
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
8386
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8901
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...
0
8660
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
7415
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...
0
4209
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
4390
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2799
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2041
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.