Solved

ASP.NET Enter vs. Button Click in Modal Popup

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
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…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

708 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now