Click here to Skip to main content
14,302,993 members

Sample Code for Ajax in, with Ajax.dll

Rate this:
2.41 (19 votes)
Please Sign up or sign in to vote.
2.41 (19 votes)
6 Feb 2007
This project is used to easily understand and implement Ajax in , ASP.Net with Ajax.dll
Sample image


Ajax stands for Asynchronous Javascript and XML. Beginners may feel hard when they want to learn Ajax. They may got confused when they get into the samples like Atlas. This article is mainly for beginners of Ajax. The sample code is very easy and self-understandable.

Using The Code

Download the source code , unzip it and configure it in your IIS. The folder "Ajax_CSharp.Net" contains a sub-folder named "DB Table". This sub-folder contains a sql file. Execute the sql in your local sql server. A table with the name "employee" will be created. Add some more data into the table with the insert query in the sql file.

Execute the project Click the button. The button is a html button.It takes employee data from the table 'employee' without page post-back and populate the data in the dropdownlist. When a particular record is selected in the dropdownlist, the selected employee name and employee id willl be displayed in the label.

What is Ajax?

Ajax stands for Asynchronous Javascript and XML. It is a browser technology. This is an combination of Javascript and XML. The data is transfered in the form of XML. XMLHttp object is used in Ajax.

Why Ajax?

Ajax is used to eliminate round-trip to the server, when a request is posted to the server. In simple, we can say that when we want to access the database without page refresh, we can use Ajax.

Source Code

protected void Page_Load(object sender, EventArgs e)

    public string GetData()
    //contains function to hit database

Using Javascript

Javascript plays an vital role in Ajax. The server side function GetData() is a Ajax function. The function is coded with "[Ajax.AjaxMethod(HttpSessionStateRequirement.ReadWrite)]" which shows that it is an Ajax function. This function is called from javascript in the click event of the button.

The server side function returns some value which is again handled by the javascript. HttpSessionStateRequirement.Readwrite is an optional argument which is used in order to use session variables inside ajax function. One thing we have to remember is that we can't access server side controls inside the GetData() function. Thats why we are returning the data to the javascript and populate dropdownlist from the javascript.

function GetData()
        var response;
    function GetData_CallBack(response)
        var response=response.value;
     // code to handle response value


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Bala Murali S
Web Developer
India India
No Biography provided

Comments and Discussions

GeneralMy vote of 5 Pin
jeevav10-Aug-10 19:11
memberjeevav10-Aug-10 19:11 
GeneralSuperrrrr man, kazhakal kazhai...india va kokka....mmmuack Pin
vsstephen27-Jul-10 18:35
membervsstephen27-Jul-10 18:35 
GeneralGood start Pin
Waruna3-Oct-09 17:56
memberWaruna3-Oct-09 17:56 
GeneralNeeds more Pin
fly90417-Mar-09 6:23
memberfly90417-Mar-09 6:23 
QuestionNot working for Firefox Pin
Member 83707622-Jan-09 7:19
memberMember 83707622-Jan-09 7:19 
GeneralCould not find the project file Pin
HemJoshi10-Sep-08 22:22
memberHemJoshi10-Sep-08 22:22 
GeneralRegarding Ajax drop down with Text box Pin
Mani Kumar21-Feb-08 21:37
memberMani Kumar21-Feb-08 21:37 
GeneralHelps beginners Pin
webqa30-Apr-07 19:14
memberwebqa30-Apr-07 19:14 
GeneralIt's Useful Pin
Florence Juliet J9-Feb-07 18:44
memberFlorence Juliet J9-Feb-07 18:44 
GeneralWhere is the javascript Pin
Not Active7-Feb-07 2:26
mentorNot Active7-Feb-07 2:26 
GeneralRe: Where is the javascript Pin
Bala Murali S8-Feb-07 19:59
memberBala Murali S8-Feb-07 19:59 
GeneralRe: Where is the javascript Pin
Not Active9-Feb-07 2:23
mentorNot Active9-Feb-07 2:23 

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

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

Posted 6 Feb 2007


21 bookmarked