Overblog Follow this blog
Edit post Administration Create my blog
Balavardhan Reddy Narani

Articale on Ajax

March 9 2009 , Written by Balavardhan Reddy Published on #ASP.Net


Ajax (also known as AJAX), shorthand for "Asynchronous JavaScript and XML", is a development technique used for creating interactive web applications. The intent is to make web pages feel more responsive by exchanging small amounts of data with the server behind the scenes, so that the entire web page does not have to be reloaded each time the user requests a change. This is intended to increase the web page's interactivity, speed, functionality, and usability.

Figure 1: The traditional model for web applications (left) compared to the Ajax model (right).

An Ajax application eliminates the start-stop-start-stop nature of interaction on the Web by introducing an intermediary — an Ajax engine — between the user and the server. It seems like adding a layer to the application would make it less responsive, but the opposite is true.

Instead of loading a web page, at the start of the session, the browser loads an Ajax engine — written in JavaScript and usually tucked away in a hidden frame. This engine is responsible for both rendering the interface the user sees and communicating with the server on the user’s behalf. The Ajax engine allows the user’s interaction with the application to happen asynchronously — independent of communication with the server. So the user is never staring at a blank browser window and an hourglass icon, waiting around for the server to do something.

Implementation AJAX in ASP.Net

Step 1).
 Down Load Ajax dll from above link add to References to Web Application
Step 2).
 Set Web.Configure file Http Handlers Section

<add verb="POST,GET" path="ajax/*.ashx" type="Ajax.PageHandlerFactory, Ajax"/>
</ httpHandlers>

Step 3).
Where you need to bring data from Database with out Refreshing Page, for those events you need to
write code in Ajax Methods

public int calback()
//Write code to connect Database and return data
Step 4).
To call Ajax Method by JavaScript, the methods which are lies in a Dot net Class
you need to add that class to AJAX, Utility in the Page load Event of ASPX Page

Ajax.Utility.RegisterTypeForAjax(typeof(Employee)); //Employee is Class Name

Step 5).
After Adding Dot net Class to Ajax, Utility. you can call those ajax methods which are lies in
that Class by the JavaScript function

function calajaxmethod()
Employee.calback(Callbackscriptfunction); //Calling Ajax Methods which lies in Employee Class

function Callbackscriptfunction(returnvalue) //After Return the Values from Ajax method
{ //storing return value in a text box
document.form1.text1.value = returnvalue.value;

step 6).
When Ever you call the JavaScript calajaxmethod() in an any Event it can call the Ajax method in
Dot net Class file, where you made the Database Connectivity to Bring value from Data base.

Share this post

Repost 0

Comment on this post