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

  • Thread starter Thread starter Paul W
  • Start date Start date
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.
 
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.
 
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.
 
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
 
Back
Top