Click here to Skip to main content
Click here to Skip to main content

Using Microsoft ATLAS/Ajax - Zip Code Updater Application

, 7 Aug 2006
Rate this:
Please Sign up or sign in to vote.
Zip Code Updater is an ASP.NET 2.0 application written in C# (2.0) that demonstrates how an object on the server side can be updated using Microsoft ATLAS (the Microsoft Ajax component).

What Zip Code Updater Does

Zip Code Updater demonstrates how an object on the server side is updated using ATLAS (the Microsoft Ajax component).

As an example; imagine that we have a database with all the zip codes from USA that allows us to lookup the city for a particular zip code. When the user types in the zip code, the code looks up the city name. When the user clicks on save, the complete address is updated on the server side. The server can only save an address if it has a zip code with the corresponding city name (business rule).

Sample image

Figure 1: GUI of Zip Code Updater

Here is the summary of what this program does:

  • Application uses ASP.NET 2.0 framework and shows how a server side object is updated using Microsoft ATLAS/Ajax component.
  • Application reads Zip Code as input from user and searches for the corresponding city from a server. The application reads the complete address of city from user and updates this information on the server side using ATLAS ScriptManager.
  • The list of city and its name, address and zip-code are hard-coded in the application.

There are two use cases:

  1. Use Case 1: Query City
    • Actors: Web-User (Initiator)
    • Purpose: Query a city name for a given zip-code
    • Overview: Web-user navigates to the web-site with a zip-code. On competition, web-user finds the city name for the zip-code.
    • Typical Course of Events: This use case begins when web-user arrives at Zip Code Updater web site. Web user enters zip code and initiates a search. The system validates web-user input for empty string. If validation fails, informs user of the failure. System shows a city name. Web-user continues with Update City User Case.
  2. Use Case 2: Update City Use Case
    • Actors: Web-User (Initiator)
    • Purpose: Update a city address for a given zip-code
    • Overview: Web-user navigates to the web-site with a zip-code and its address. On completion, web-user updates the city’s address.
    • Typical Course of Events: This use case begins after successful completion of Query City use case and web-user has address of the city. Web user enters zip code, city name and its address and initiates an update. The system validates web-user input for empty string and for a matching zip-code with city-name. If validation fails, informs user of the failure. System updates city address and shows the result. Web-user leaves the Zip Code Updater web site.

Design of Zip Code Updater

The design of the Zip Code Updater application is divided into two software components. These are Graphical User Interface and Web Service. Following is the description of each of the components.

Graphical User Interface

The above Figure 1 shows a graphical user interface of the Zip Code Updater application. The top part of the GUI is used to execute Query City use case. When the user enters a valid zip-code in Search Zip Code edit-box and clicks Search button, this part of the GUI validates the input for empty string and sends a Web-Service ATLAS/Ajax request to the server. On response from web service, if the response is a success, it updates Zip Code and City fields of the lower-part of the GUI. If response indicates a failure, it displays an error message. The bottom part of the GUI is used to execute Update City user case. When user enters a Zip Code, City and Address in corresponding edit boxes and clicks the Save button, this part of the GUI validates the input for empty string and sends a Web-Service ATLAS/Ajax update request to server. On response from web service, if the response is a success, then it displays a success message. If response indicates a failure, it displays an error message.

Web Service

The Zip Code Service is implemented as a Web Service that is hosted on IIS. This web service maintains a list of pre-defined City information in a City Hash Table with the following information stored in each of the entries. Zip Code: City zip code, City Name: Name of the city with corresponding zip-code, Address: Address of the city. Zip Code is used as hash key in hash-table. Hash-table is searched for zip-code and a city name. Also, upon update request, a matching zip-code and city-name is searched from the hash-table and, if found, the corresponding address is updated. The Zip Code Service provides two different methods to support two use cases described above. This section described these two interfaces.

  • GetCityName: This web-service interface is used to query the city name for a given zip code. Input Parameters are Zip Code of the city whose name is being queried. It returns City Name which is the Name of the corresponding city if found or “1”, indicating that the corresponding city is not found. This web-method accesses City Hash Table from Application object for a given zip-code. If found, it returns the corresponding city name, otherwise, it returns an error code “1”. To synchronize the access of City Hash Table, it locks Application object before accessing City Hash Table, and un-locks Application object when it is done accessing City Hash Table.
  • SetCityInfo: This web-service interface is used to update the city address for a given zip code and city name pair. Input parameters are Zip Code of the city whose address is being updated, City Name of the corresponding city whose address is being updated, and Address of the corresponding city. Result returned is Status of “0”, indicating success or “1”, indicating corresponding city is not found or “2”, indicating zip-code and city name mismatch. This web-method accesses City Hash Table from Application object for a given zip-code. If an entry is found, then it validates that city name and zip code parameters match the one from City Hash Table. If there is a match, then it updates the corresponding address and returns a success “0”. If the corresponding city name for a given zip-code is not found, it returns an error code “1”. If there is a mismatch between city-name and zip code, it returns an error code “2”. To synchronize the access of City Hash Table, it locks the Application object before accessing the City Hash Table, and un-locks Application object when it is done accessing the City Hash Table.

How to Install Zip Code Updater

To install, follow the steps below:

  • Download the demo zip file and unzip in a folder. ZipCodeUpdate can also be downloaded from Mildwave.com by clicking here.
  • Launch File Explorer and locate setup.exe and double click setup.exe to start installation.
  • Click Next all the way to confirm installation. Installation begins.
  • Click Close to complete installation.
  • Installation program creates a ZipCodeUpdater virtual application. Right click ZipCodeUpdater and click Properties. Click ASP.NET tab and then click ASP.NET version Combo-Box and select 2.0.X.
  • Make sure that C:\Temp directory exists on the local computer.

To un-install, follow the steps below:

  • Run Add/Remove Program from Control Panel.
  • Click on Change or Remove program and click on “Zip Code Updater Using ATLAS/Ajax” program.
  • Click on Remove button and confirm by clicking on Yes. Un-installation begins.
    Un-installation is completed.

How to Test Zip Code Updater

Test Setup

Run Internet Explorer and type http:\\localhost\ZipCodeUpdater to launch the application.

Address Table

(92821, Brea, CA), (91710, Chino, CA), (91713, Fullerton, CA), (91714, Irvine, CA), (91715, Boulder, CO), (91716, San Diego, CA)

Test Scenarios

  • Valid Zip Code Search: Enter 92821 in Search Zip Code field and Click Search button. Zip Code field is updated with 92821 and City field is updated with Brea.
  • Empty Zip Code Search: Clear Search Zip Code field and click Search button, an Error message for empty search is displayed.
  • Invalid Zip Code Search: Enter 92822 in Search Zip Code field and click Search button. Error message for unknown zip code is displayed.
  • Valid Address Update: Enter 92821 in Zip Code field, Brea in City field and California in Address field. Click Update button. Success message is displayed. C:\Temp\UpdateLog.xml file is updated with new values.
  • Empty Address Update: Clear Search Zip Code, City and Address fields and click Update button. Error message for empty update is displayed.
  • City and Address Mismatch: Enter 92821 in Zip Code field, Irvine in City field and California in Address field and click Update button. Error message for mismatch is displayed.

Source Code and Demo Zip Files

  • Download source zip file and unzip in a folder. Open the solution and run/debug the application.
  • Download demo and unzip in a folder and run setup.exe to install this application.
  • ZipCodeUpdate can also be downloaded from Mildwave.com web-site by clicking here.

Summary

The Zip Code Updater program demonstrates the usage and new trends in developing web-applications using Microsoft ATLAS/Ajax technology.

History

  • 8th August, 2006: Initial post

License

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

Share

About the Author

Rajiv K Singh
Web Developer
United States United States
Rajiv K Singh is a Software Architect with MS in Computer Science from California State University, Fullerton, CA. He has 10+ years of experience in architecture, design and software development for enterprise using C++, C#, ASP.NET. His current area of interests are SOA, Web Services, BizTalk, ADO.NET and ASP.NET. Rajiv Singh can be reached at rajivks@hotmail.com.

Comments and Discussions

 
QuestionFormatting? Pinmembermwdiablo7-Aug-06 23:49 
AnswerRe: Formatting? [modified] PinmemberRajiv K Singh8-Aug-06 11:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web04 | 2.8.140827.1 | Last Updated 8 Aug 2006
Article Copyright 2006 by Rajiv K Singh
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid