?
Solved

ASP.NET Enter vs. Button Click in Modal Popup

Posted on 2009-04-10
3
Medium Priority
?
575 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 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

801 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