Invoke code behind image-button with <Enter> key from anywhere on form

P

Paul W

On my simple login-screen I have a 'username' and 'password' field and an
imagebutton for the 'OK'.

This used to work nicely so that when the user hit <Enter> from the password
field, it invoked the VB code behind the image-button, and away he went.
Suddenly this has stopped working like this. It still works if you use the
mouse to click on the button, or first TAB to it, then click <Enter>.
However, if you now hit <Enter> with the cursor still in the 'password'
field it submits the form, runs Page_Load, but doesn't call the
image-button's click event.

A 'working' version is at
http://www.mystictennisbookings.com/admin/login.aspx . FYI - what I did that
seemed to break it was to replace the Textbox webcontrol that I used for the
'Username' field with a Dropdown webcontrol.

Any ideas how I can restore the required functionality? Thanks,

Paul.
 
P

Paul W

The link I sent is to the original version that works as desired - hitting
<Enter> from the password field here will invoke the code behind the
image-button.

There's a copy of the version that does NOT work at
www.mystictennisbookings.com/admintest/login.aspx - here if you hit <Enter>
from the password field it submits the form but doesn't execute the
image-button event.

Paul.

Paul.
 
G

Guest

Paul W said:
On my simple login-screen I have a 'username' and 'password' field and an
imagebutton for the 'OK'.

This used to work nicely so that when the user hit <Enter> from the password
field, it invoked the VB code behind the image-button, and away he went.
Suddenly this has stopped working like this. It still works if you use the
mouse to click on the button, or first TAB to it, then click <Enter>.
However, if you now hit <Enter> with the cursor still in the 'password'
field it submits the form, runs Page_Load, but doesn't call the
image-button's click event.

A 'working' version is at
http://www.mystictennisbookings.com/admin/login.aspx . FYI - what I did that
seemed to break it was to replace the Textbox webcontrol that I used for the
'Username' field with a Dropdown webcontrol.

Any ideas how I can restore the required functionality? Thanks,

Paul.
 
D

Daniel Walzenbach

Paul,

what you basically have to do is to assign a tiny js function to the keydown
event of your password input field which will trigger the ok.click.

HTHs

Daniel
 

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

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,740
Latest member
JudsonFrie

Latest Threads

Top