Enter Key trapping in aspx with ImageButton

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi Experts

I have an aspx page in which I am providing a search facility apart from
other matters. I have placed an image button. I have several dropdown lists
and textboxes in the page to provide the search criteria. I want the
imagebutton click to be fired when the user clicks the "Enter" key from
anywhere in the page, even without clicking on any of the controls.

Is there any way to achive this??

Thanks in advance

Regards
Ganesh
 
Hi Ganesh,

This won't take you long at all. In your <body> tag put:

onkeypress="CheckSubmit();"

Then create your CheckSubmit() javascript function:

function CheckSubmit() {
if (event.keyCode == 13) { //Did they hit enter?
Form1.submit();
}
}

That's it. Now your form will submit when the user hits enter. Good luck!
Ken.
 

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

Back
Top