ASP.NET Enter vs. Button Click in Modal Popup
Posted on 2009-04-10
I have a modal popup box that has an "Ok" button and a "Cancel" button, as well as a text box for the user to enter their zipcode. If somone clicks a link on the page called "Change ZipCode", the modal popup appears, and they can type it in.
Two things don't happen correctly:
1. The text box doesn't have focus - so, when the popup appears, the user has to click in the box to enter their zipcode. Not the end of the world, but it would be nice if that worked right.
2. If a user types in their zipcode and presses enter, the box closes, but doesn't actually run the code i need that is associated with the "Ok" button. So basically, if the user clicks the "Ok" button after typing in the zipcode, everything works fine. If the user enters the zipcode in and presses the enter key, the popup closes, but nothing else happens.
I'm not sure how to setfocus on the "enter" text box and then setfocus on the "ok" button. Or, how do i check the "enter" key for a keypress?
Thanks for your help!
(I'm programming in VB)