server click event on enter press

C

csgraham74

Hi there,


I have just written an applcation in asp.net. In testing i have found
that the enter key press on a button does not fire a javascript confirm
prompt. is there anyway i can get this to fire the event when the
button is selected and enter is pressed.

basically i want code to check if enter key is pressed or button is
clicked then display a message:

i have the following code for the click event:-

btn_AccountSearch.Attributes.Add("onclick", _
"return confirm('Yess or No ?');")

hope this makes sense


thanks in advance
 
M

Mike Labosh

I have just written an applcation in asp.net. In testing i have found
that the enter key press on a button does not fire a javascript confirm
prompt. is there anyway i can get this to fire the event when the
button is selected and enter is pressed.

What I have done in the past for this is to use the onsubmit event of the
form. That way, whether the user clicks the button or presses enter on it,
my onsubmit javascript will still run, and then as a bonus I can optionally
cancel the submit by having my javascript function return false.

--
Peace & happy computing,

Mike Labosh, MCSD

"Mr. McKittrick, after very careful consideration, I have
come to the conclusion that this new system SUCKS."
-- General Barringer, "War Games"
 
S

snt

This should work fine. I have done this. View source and see if its
rendered correctly to the element. Try adding protocol "javascript:"
to your javascript function just as below:
btn_AccountSearch.Attributes.Add("onclick", _
"javascript:return confirm('Yess or No ?');")

to avoid any script related issues.

snt
http://www.onlinemall.com
 
C

csgraham74

This only refers to the on click event. i need something that works for
the onclick and the enter press on the control.

thanks for ur help though. i need something to capture the keycode 13 i
think.
 
C

csgraham74

This only refers to the on click event. i need something that works for
the onclick and the enter press on the control.

thanks for ur help though. i need something to capture the keycode 13 i
think.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top