|
The CityStateFinder component is a class library that allows a developer to
find city and state information for any given zip code. Utilizing the UPS XML
web server, which is updated continually by the USPS AV database, the
information is always up-to-date and as accurate as possible. The city and
state retrieved will always be the same as on record with the United States
Postal Service.
This component in accordance with standards for using the UPS XML Web Service,
submits an AccessKey, UserID, and Password with every submission sent from the
component. Currently, a generic AccessKey, UserID, and Password are embedded in
the control which allows the developer to present nothing and do nothing but
run the control. For development it is acceptable to simply use this, meaning
that nothing needs to be added or done to the asp.net code. For all production
software that is deployed however, an AccessKey, UserID, and Password must be
retrieved from UPS via their web site. The UPS registration for such is free.
See the picture to the right. To submit your registered AccessKey, UserID, and
Password via the component, you will need to write several lines into the
Web.config file of your asp.net application. The code is as follows:
| <appSetting> |
| <add
key="CSF_AccessKey"
|
| value="GX223R4572DF7H38721" |
| />
|
| <add
key="CSF_UserID"
|
| value="jonsmith" |
| />
|
| <add
key="CSF_Password"
|
| value="abc123" |
| />
|
| </appSetting>
|
Again, registering at the UPS web site and entering the above information into
your Web.config is not necessary to make the component work, but should be done
for all deployed applications. In particular, this component has two classes
that are important. The first is the CityStateFinder class which a simple
SearchOn method. The second class is used to catch the output from the SearchOn
method and is called CityStateLocations. A developer can implement this
component in less than five lines of code. The following is an example of how
it is used.
| Dim
locations() As CityStateLocations =
CityStateFinder.SearchOn("90210", True)
|
In this example, the SearchOn method will search for the zip code "90210" and
return an array of CityStateLocations. The SearchOn method is overloaded with a
second parameter that may be used. This parameter is of type boolean, and
denotes whether the returned locations should be in proper case alphabetically.
Listed below are all the methods are properties that are implemented with this
control.
|
 |
City |
Gets, as string, the City
part of the location that is returned. |
 |
Quality |
Gets, as double, the Quality
of the location that is returned. This is determined by the web service. |
 |
Rank |
Gets, as integer, the Rank or
probable order of the location that is returned. It is always good to use Rank
1. |
 |
StateAbbreviation |
Gets, as string, the State
part of the location that is returned. Sets the format as a two letter
abbreviation. |
 |
StateName |
Gets, as string, the State part of the location that is returned. Sets the
format as fully spelled out. |
|