Solved

ASP.NET Enter vs. Button Click in Modal Popup

Posted on 2009-04-10
3
574 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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
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…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

717 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