Control where 'Enter Button' takes you

G

Guest

Hi there..
I write in a textbox to search for something on my asp.net page and when i
click the enter button, i want the Find button to be activated..
instead, one of the other buttons is being pressed. I found this code but
it is not working... any ideas???

<body onkeydown="if(event.keyCode == 13)
{document.getElementById('myBtn').click();}">
 
G

Guest

Normally, when the controls rendered in the browser one of the control will
receive the default focus. Change this order and make your search button to
get the default focus, that's all..no need write any scripts..

Regards,
thangam
 
W

William F. Robertson, Jr.

Try returning false from the event.

if ( event.keyCode == 13 ) { document.all["myBtn"].click(); return false; }

See if that works.

What is it doing currently?

bill
 

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

Top