?
Solved

ASP.NET Enter vs. Button Click in Modal Popup

Posted on 2009-04-10
3
Medium Priority
?
578 Views
Last Modified: 2012-06-21
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)
 
0
Comment
Question by:steverguy
  • 2
3 Comments
 
LVL 5

Expert Comment

by:brandonvmoore
ID: 24118955
The ideal way to implement this kind of thing is to use javascript as it is a client-side scripting language and you don't need the user to request a new page when they enter a zipcode.

The only way asp.net has any awareness of what's happening on the client side is when the client requests a new page.  This happens whenever the user clicks the submit button, but not when they fill in a message box.  There are some AJAX tools built into vb you could use to accomplish this, but that would probably be overkill.

Go to w3schools.com and spend a couple hours learning to write javascript.  Even if there is a simpler way to do this purely in asp.net that I am not thinking of, I still think that javascript is the best solution for you.
0
 
LVL 5

Accepted Solution

by:
brandonvmoore earned 2000 total points
ID: 24118974
I meant to mention that you 'can' manually submit the page when the message box gets filled in.  For the actual code to do this you'll have to wait for someone else to give you that since I don't work with ASP.net enough to know that off the top of my head.  However, javascript is still the way to go for the clientside stuff and you should look into implementing it that way.
0
 
LVL 1

Author Closing Comment

by:steverguy
ID: 31569055
Thanks, wasn't sure if i could do it with VB.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question