Solved

ASP.NET Enter vs. Button Click in Modal Popup

Posted on 2009-04-10
3
573 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 500 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

738 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