Ajax (Asynchronous JavaScript And XML) enables your client-side
web pages to exchange data with the server through asynchronous calls. AJAX is
a platform-independent technology that works with Web applications. Every time
a user performs some action on a page, the entire page will sent to the server.
Whenever you perform a postback the page jumps, and the user must wait until
the page gets reconstructed. By using AJAX you can create refresh partial page
without a full reload and without affecting other parts of the page.
Traditional Page Processing
A user types the address of required page in the address bar of web browser and
sends the request to web server by using HTTP protocol. Web server processes
the request and then sends a response back to the Web browser. The HTTP
protocol is used to send the HTTP response back to the Web browser. The user’s
Web browser then processes the response and renders the Web page for display to
the user.
This process is repeated over and over during a typical Web application
session. For every postback whole page is processed.
Ajax Page Processing
By using AJAX you can create flicker-free pages that enable you to refresh
partial page without a full reload and without affecting other parts of the
page. AJAX provides you rich, client-side programming to access and modify data
in your page.
Benefits of ASP.NET AJAX
Partial-page updates
Client-side processing
Desktop-like UI
Improved performance
Provide Platform Independency
AJAX Server Controls
These controls works in a similar manner as other ASP.NET controls. You can drag
and drop them onto your page. Each of these controls inherits from the
System.Web.UI.Control class.
The following ASP.NET AJAX server controls that come with ASP.NET
ScriptManager
ScriptManagerProxy
Timer
UpdatePanel
UpdateProgress
ScriptManager Control
If you want to use ASP.NET AJAX than you must have ScriptManager Control. The
ScriptManager control manages the communication between the client page and the
server. It manages also manages the JavaScript files used at the client, takes
care of partial-page updates. You can directly drag and drop this control on
content page. It does not have a visual representation. It only used to manage
AJAX processing. You cannot use more than one ScriptManager control on single
web page.
The ScriptManagerProxy control mainly used when we deals with Master Pages. The
ScriptManagerProxy control can be used by content pages that use a master page.
The Master page must have a ScriptManager control otherwise you will get error.
UpdatePanel control is the most important control in Microsoft’s server-side
AJAX framework. The UpdatePanel control enables you to update a portion of a
page without updating the entire page. With partial-page updates you can post
portions of a page to the server and only receive updates to those portions.
The UpdatePanel control is work as a container for other controls.
Example:
Add a ScriptManager server control to the top of the page.
Add one label and one button on the page name Label1 and Button1.
Add UpdatePanel control and take another label and button named Label2 and
Button2.
Remember that Label1 and Button1 server control are outside the UpdatePanel
control but Label2 and Button2 server control are inside the UpdatePanel
control.
When you click first button the complete page get refreshed and updates the
current time in the Label1 server control but Clicking on the second button
updates the current server time in the Label2 server control. When you click
the button1, the time in Label1 will not change at all, as it is outside of the
UpdatePanel.
Timer Control
The ASP.NET AJAX Timer control enables you to refresh an UpdatePanel in fixed
time interval. The Timer control has one important property named Interval. You
can specify the amount of time, in millisecond. The default value is 60,000 (1
minute).
The Timer control raises a Tick event automatically depending on the value of
its Interval property.
In the above given example every 10 seconds Timer1_Tick () function will be
called.
UpdateProgress Control
The UpdateProgress control allows you to show to the user that work is being
done and that they will get results soon. You can show the status of work done
by using this control.