Introduction to ASP.Net Ajax Part 1

Ajax was a hot buzzword for quite a period of time.Ajax is neither a new programming language nor a new platform for building web sites.Ajax is not a new technology but you can say a new technique, which is built on existing technologies like JavaScript,XML,DHTML,CSS and so on.It is used for creating fast and dynamic web pages. Examples of applications using AJAX are Google Maps, Gmail,Facebook etc.

What is Ajax?

As you all know Ajax is Asynchronous JavaScript and XML. As it name implies ajax is a group of interrelated web development techniques which are used to create highly interactive dynamic web applications.

As I told earlier ajax is not a single technology, but it's a combination of many technologies. Following are the widely used techniques in Ajax.

i) JavaScript: JavaScript is used to make request to the webserver as well as get response from the web server.

ii) DHTML and CSS: They are used to show the output to the user.

iii) XMLHttpRequest object: The XMLHttpRequest object can be used to send asynchronous request to the web server. Note that these requests are asynchronous in nature hence there is no need to wait for the response to come back. Hence its faster.

iv) XML : XML can be used to receive the data returned from the server.

v) Json : Json/JavaScript can be used to process the XML data returned from the web server.

vi) Vb Script : Vb script can also be used instead of Javascript.

vii) XHTML : XHTML is used to ensure that ajax enabled web site runs consistently with all the browsers.

viii) DOM : Ajax uses DOM to update the content of a web site whenever required.

Why Ajax?

Classic web application is based on request response model or post back model or they are synchronous in nature.What does that mean? ie;user make some request on the server. Server processes the request and responds with a new page. User needs to waits for the response to come back.This process is time consuming.There will a server round trip for each request and response.It will impact performance of the application.

Here comes the importance of ajax. The heart of ajax is the ajax engine .With ajax, the web applications can retrieve data from the server asynchronously in the background without interfering with display and behavior of the existing page. You can do these things without refreshing your page.

Ajax Life Cycle

Ajax life cycle is quite different from classic web application life cycle.In Ajax life cycle ajax engine will work as a mediator between client and Web server by sending request to the server and receiving response from the server.There are 3 major stages in ajax communication model. They are:

i) User Visit the Page: User visit the page first time.

ii) Initialization of Ajax Engine: This happens automatically in the back ground when the page is initially loaded.

iii)Event processing: Browser event may instruct the ajax engine to send a request to the server.Once the ajax engine receives the response from the server, it calls the JavaScript callback functions to update the browser.


When the user visits page first time, ajax engine is initialized and loaded in the background.Here ajax engine comes in to picture.From next request onwards,the user interacts with ajax engine asynchronously instead of directly sending request to the server like classic web application.Here sending request to the server and receiving response from the server happens without any post back and so there is no page refesh.This make ajax application highly interactive.

You can see the differences in life cycles between classic web application
and ajax enabled applicaion in the figure given in the appendix.

ASP.Net 4.0 Ajax Features

ASP.Net 4.0 ajax includes many new features which provide more functionality to the user.They are :

1. support for live data binding .
2. support for client side template rendering .
3. support for declarative instantiation of client components .
4. support for using the observer pattern on javascript object and arrays .
5. support for invoking ADO.Net data services and data contexts .
6. support for the data view model .
7. Jquery Integration.

ASP.Net Ajax architecture

ASP.Net Ajax architecture can be devided in to 2 catagories.

a) client side architecture : client side architecture is the client script that a web application uses to call an application or a service on the server.
b) server side architecture : server side architecture comprise of ASP.Net web services,ASP.Net server controls,ASP.Net ajax extension controls etc.


The following are main advantages of using Ajax.

1.Ajax can be used for creating rich web based applications.
2.The ajax is based on JavaScript and existing technologies such as XML, CSS, DHTML and so on.So the learning curve is very short for the developers.
3.Ajax can be used to create web applications without refreshing the whole page.


Like there are many advantages, ajax have few disadvanges too.However there are some work around to resolve them.

1. It has an inherent issue with the back button: Dynamically created pages do not register themselves with the browser's history engine,so clicking the browser's "Back" button does not return the user to an earlier state of the Ajax-enabled page. However, it instead returns them to the last page visited before it.
2. Ajax enabled pages have some difficulty to bookmark a particular state of the application.
3. Any user whose browser won't support ajax or javascript or if simply javascript disabled will not be able to use this functionality.
4. There is a lack of a standards body behind Ajax.
5. Devices such as mobile phones, PDAs, and screen readers may not have support for JavaScript or the XMLHttpRequest object. Also, screen readers that are able to use Ajax may still not be able to properly read the dynamically generated content.
6.Since most web crawlers do not execute JavaScript code, web applications
should provide an alternative means of accessing the content that would normally be retrieved with Ajax, to allow search engines to index it.
Classic Web Application Model Vs Ajax Communication Model



No responses found. Be the first to comment...

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: