输入邮政编码后,应自动显示城市和州 [英] Once zipcode is entered then city and state should be automatically displayed

查看:108
本文介绍了输入邮政编码后,应自动显示城市和州的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有三个文本字段,邮政编码,城市和州.输入邮政编码后,应自动在texboxs中自动填写城市和州.

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

推荐答案

您需要找到一些提供 ZIP代码查找的服务.从您的个人资料中可以看到,您在美国,对吗?因此,可能是这样的:
http://www.zip-codes.com/search.asp [ Web服务 的形式提供服务会更方便.这是一个:
http://www.webservicex.net/uszip.asmx [ 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/库/vstudio/7h3ystb6%28v=vs.100%29.aspx [ http://johnwsaunders3.wordpress.com/2009/05/17 /how-to-consume-a-web-service/ [ Web抓取:
http://en.wikipedia.org/wiki/Web_scraping [从网页中获取特定数据 [如何从另一个站点获取数据 [ ^ ].

我希望您不需要它,因为使用Web服务会更好.

祝你好运,
—SA
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


这篇关于输入邮政编码后,应自动显示城市和州的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆