Introduction to ASP.Net Ajax Part 1
What is Ajax?
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.
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.
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.
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 asp.net 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.
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 .
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.
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.
4. There is a lack of a standards body behind Ajax.
should provide an alternative means of accessing the content that would normally be retrieved with Ajax, to allow search engines to index it.