472,351 Members | 1,579 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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 4829
Do this in you r/javascript function hooked to any where
on textbox etc.

function abc()
{
if(window.event.keyCode == '13')
{
document.getElementById(yoursubmitnuttonid).click
();
event.returnValue = false;
}
}

event.returnvalue 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.getElementById(yoursubmitnuttonid).click
();
event.returnValue = false;
}
}

event.returnvalue 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***************@TK2MSFTNGP10.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***************@TK2MSFTNGP10.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
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...
10
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...
2
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...
2
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...
2
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...
4
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...
3
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 -...
5
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...
18
by: navyjax2 | last post by:
What if your event handler has to be nonstatic?
1
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....

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.