Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
i have three text fields, zip,city and state.Once the zip code is entered, then automatically the city and state should be auto-filled in the texboxes.
<label>ZipCode</label>@Html.TextBoxFor(x => x.Zipcode)
<label>City</label>@Html.TextBoxFor(x => x.City)
<label>State</label>@Html.TextBoxFor(x => x.State)
how can i do this, can anyone help
Posted 11-Oct-12 6:16am
Edited 11-Oct-12 12:13pm
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You need to find some service which provides the ZIP code lookup. As I can see from your profile, you are in U.S., right? So, it could be like this one:
http://www.zip-codes.com/search.asp[^].
 
It would be more convenient to get a service with is provided as a Web service. Here is one:
http://www.webservicex.net/uszip.asmx[^].
 
This site provides dual service: you can do the ZIP code lookup through a Web browser as a human operator, or create a Web service client using provided WSDL, which the most convenient way to use the service in your code. I think, you will be able to find other services of this kind. You can do your search and refer to the documentation of the service provider on the services' sites.
 
If you are given WSDL, as in this case, the solution is quite easy. Please see:
http://msdn.microsoft.com/en-us/library/ms996486.aspx[^],
http://msdn.microsoft.com/en-us/library/6h0yh8f9%28v=vs.80%29.aspx[^],
http://msdn.microsoft.com/en-us/library/vstudio/7h3ystb6%28v=vs.100%29.aspx[^].
 
This is some walkthrough article showing how to consume such Web service, with examples:
http://johnwsaunders3.wordpress.com/2009/05/17/how-to-consume-a-web-service/[^].
 
If, by some reason, you need to use a "regular" Web site oriented for the use of a human operator using the browser, for a lookup of just about anything, you would need to use the techniques of Web scraping:
http://en.wikipedia.org/wiki/Web_scraping[^].
 
Please see my past answers:
get specific data from web page[^],
How to get the data from another site[^].
 
I hope you would not need it, because consuming a Web service is way better.
 
Good luck,
—SA
  Permalink  
v4
Comments
Sushil Mate at 11-Oct-12 12:34pm
   
my 5 for your effort :)
Sergey Alexandrovich Kryukov at 11-Oct-12 12:38pm
   
Thank you, Sushil.
--SA
Marcus Kramer at 11-Oct-12 17:13pm
   
+5. Excellent.
Sergey Alexandrovich Kryukov at 11-Oct-12 17:16pm
   
Thank you, Marcus.
--SA
Member 9359591 at 12-Oct-12 12:19pm
   
thnq so much..
Sergey Alexandrovich Kryukov at 12-Oct-12 12:36pm
   
You are welcome.
Are you going to accept it formally (green button)?
--SA
Member 9359591 at 24-Oct-12 19:44pm
   
yes i did..
Sergey Alexandrovich Kryukov at 24-Oct-12 21:30pm
   
Great, thanks.
Good luck, call again.
--SA
Member 9359591 at 25-Oct-12 13:29pm
   
Thank you and good luck to you to..
Sergey Alexandrovich Kryukov at 25-Oct-12 14:57pm
   
:-)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 8,284
1 Sergey Alexandrovich Kryukov 7,407
2 DamithSL 5,614
3 Maciej Los 4,989
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web03 | 2.8.1411023.1 | Last Updated 11 Oct 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100