Populating a DropDownList using AJAX and ASP.NET
 
Published: 06 Sep 2005
Abstract
AJAX is the latest buzzword in the web development industry. But what is it, and how can you use it? Ramaprasad Potturi and Sanjay Patnaik explain the technology and provide a real-world example of a web page that presents a country and state pair of drop-down lists, where the state drop-down list is populated dynamically on the client side, removing the need for the page to post back to the server.
by Ramaprasad Potturi
Feedback
Average Rating: 
Views (Total / Last 10 Days): 235357/ 1688

Introduction

In the first section of this article, we shall introduce AJAX and discuss its advantages and disadvantages. Next, we look at the XMLHTTPRequest object, its properties and functions, and how to create an instance of this object. Then, we will illustrate the use of AJAX functionality by creating a sample application. Finally, we will talk about how the sample application works. The sample application is an ASP.NET web application, written in C#, and is available for download.

What is AJAX?

AJAX stands for Asynchronous JavaScript and XML. AJAX is not a new technology; it is a new way of combining existing technologies. What we do in AJAX is create an asynchronous request to the web server using client-side JavaScript and an XmlHttpRequest object, and map a function to be executed when the response is received. An asynchronous request means that the browser does not need to wait for the response after sending the request to the server. What we gain using AJAX is a responsive user interface, and we get this by sending a request to the web server for a small amount of information, as many times as we want, without sending the complete information on the form. In AJAX, the request is for data, not for a GUI element, so an AJAX request can be handled by an ASP.NET page without any HTML content, a custom HTTP module, or a web service. The core component in AJAX is the XMLHTTPRequest object. As many web developers are not familiar with this object, we will discuss it in detail in the next section. Following are the advantages and disadvantages of AJAX.

Advantages:

  1. The use of AJAX the increases the richness and responsiveness of the web page interface.
  2. It reduces the network traffic and CPU usage on web server. This is because there will be no post back to the server that will render a complete HTML page. For example, if you are displaying a lot of data in a web page, the HTML page size may be about 100 kilobytes. This big string has to be created on the server and then sent back to the client.

Disadvantages:

  1. The use of AJAX requires users to have JavaScript enabled on their browser. Because of this, an AJAX website should provide a non-AJAX alternative for users without JavaScript enabled.
  2. AJAX breaks the normal browsers' Back button behavior. When a page is updated dynamically, returning to the previous state may not be possible, since browsers typically record only complete page requests in their history lists.
  3. As not all browsers are complying with W3C standards, AJAX applications have to be tested rigorously to deal with the quirks of different browsers.
The XMLHTTPRequest Object

The XMLHTTPRequest object is used to send a request to, and receive a response from, the web server. Using this object, the web page can make a request to the web server asynchronously, and receive a response asynchronously. Even though this object is not a W3C standard, most of the current browsers (IE5.0, Mozilla 1.0, Netscape 7.0, Safari 1.2, and Opera 8.0) have implemented this object. Hereafter I will also refer an XMLHTTPRequest object as an XMLHTTP object.

Properties and Functions of XMLHTTPRequest object used in the Sample Application

Table 1 – Properties of XMLHTTPRequest Object

Property Description
onreadystatechange The response handler function, which gets called for every change of the readyState property.
readyState The state of the receiving request.
status The HTTP status code returned by the server.
responseXML The XML document returned by the server.

Table 2 – Methods of XMLHTTPRequest Object

Function Description
open Initializes a request.
send Sends a request to the server.

Creating an Instance of an XMLHTTPRequest Object

While any browser-supported scripting language can be used to access this object, the method by which an instance of an XMLHTTPRequest object is created varies from browser to browser. Internet Explorer (IE) implements this object using ActiveX technology, so creating an instance of this object requires the use of “New ActiveXObject(ProgId)”, where ProgId is either Msxml2.XMLHTTP or Microsoft.XMLHTTP, depending on the version of MSXML installed. Mozilla, Safari, and Netscape implement this as a native object, so creating an instance requires the use of “New XMLHttpRequest()”. The following JavaScript function (Listing 1) creates an instance of an XMLHTTP object independent of browser type. The code presented for this article has been tested with IE 6.0, Netscape 8.0, and Mozilla Firefox 1.0.

Listing 1 – Creating an XMLHTTP Object

function CreateXmlHttp()
{
    //Creating object of XMLHTTP in IE
    try
    {
        XmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch(e)
    {
        try
        {
            XmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch()
        {
            XmlHttp = null;
        }
    }
    //Creating object of XMLHTTP in Mozilla and Safari
    if(!XmlHttp && typeof XMLHttpRequest != "undefined")
    {
        XmlHttp = new XMLHttpRequest();
    }
}

The Sample Application

The sample application uses a pair of DropDownList controls. A change in the selected value of the first drop-down list should populate the second drop-down list with a new collection of items. This paired behavior is found in many applications, such as a Country-State pair and a Category-Product pair. We have chosen to discuss the Country-State DropDownList pair. In traditional web applications, a change in the value of the Country DropDownList results in the web page posting back to server in order to populate the States DropDownList. In our example, we will populate the States DropDownList by retrieving state data from the server using AJAX, without submitting the entire form to the server.

In this section, first we will discuss the CountriesAndStates.xml and CountriesAndStates.xsl files, and then the CountryStateXml class which is used to get country and state data from the XML file. Next, we will discuss the start page of our project, which is AjaxClient.aspx. We will then discuss our JavaScript files, AjaxVariables.js and AjaxScript.js. You will find core AJAX code in the AjaxScript.js file. Finally we will talk about the AjaxServer.aspx page, which handles the AJAX requests.

CountriesAndStates XML and XSL Files

The CountriesAndStates.xml file stores the names of all countries and their states. The format of this XML file is shown below (Listing 2). Each country is represented as a single country node, and all of its states are represented as child nodes. At present this XML file has only three countries and some of the states of these countries. You can edit this XML to add other countries and states.

Listing 2 – CountriesAndStates.xml File

<country name="USA">
    <state>Alabama</state> 
    <state>Alaska</state> 
    <state>Arizona</state> 
    <state>Arkansas</state> 
</country>

The CountriesAndStates.xsl file has the transformation logic for converting one form of XML into another form of XML. This transformation takes a country name as an input parameter, and returns its corresponding states in an XML string.

CountryStateXml class

The CountryStateXml class is used to get country or state data in different formats depending on the method called. This class has one constructor and three public methods.  The constructor loads the CountriesAndStates.xml file into an XPathDocument. The public method GetCountryList returns a list of countries as an ArrayList. The second method GetStateList returns a list of states for a given country as an ArrayList. The third method GetStatesXMLString returns an XML document containing all the states for a given country name, along with the country name.

AjaxClient Page

The start page of our sample application is AjaxClient.aspx and Figure 1 shows it viewed in a browser. This page has two DropDownList server controls. The HTML markup of this page is given in Listing 3. The onchange event of the Country DropDownList is tied to the JavaScript function CountryListOnChange and is shown in bold text in the following markup. We will discuss the CountryListOnChange function later in this section.

Figure 1 – AjaxClient.aspx Page in a Browser

Listing 3 – HTML of AjaxClient.aspx page

<form id="Form1" method="post" runat="server">
    <asp:DropDownList id="countryList" onchange="return CountryListOnChange()" 
        style="Z-INDEX: 101; LEFT: 20px; POSITION: absolute; TOP: 28px"
        runat="server" Width="174px" Height="28px"></asp:DropDownList>
    <asp:DropDownList id="stateList" 
        style="Z-INDEX: 102; LEFT: 218px; POSITION: absolute; TOP: 28px"
        runat="server" Width="174px"></asp:DropDownList>
</form>

Listing 4 shows the code for the Page_Load method of this web page. When the page loads for the first time, this method populates the Country and State DropDownList controls using the GetCountryList and GetStateList methods of CountryStateXml class.

Listing 4 – Page_Load Method of AjaxClient.aspx Page

private void Page_Load(object sender, System.EventArgs e)
{
    CountryStateXml countryStateXml = new CountryStateXml();
    ArrayList countries = countryStateXml.GetCountryList();
    for(int index = 0; index < countries.Count; index++)
    {
        countryList.Items.Add(countries[index].ToString());
    }
    ArrayList states = countryStateXml.GetStateList(countries[0].ToString()) ;
    for(int index = 0; index < states.Count; index++)
    {
        stateList.Items.Add(states[index].ToString());
    }
}

JavaScript Code

The AjaxScript.js file includes the required AJAX script. When the selected value of the country drop-down list changes, the CountryListOnChange function is called. Now we will talk about how the asynchronous request to the server in the CountryListOnChange function works. See Listing 5.

  1. Form the request URL with the selected country in the query string.
  2. The CreateXmlHttp function (this function is explained in the earlier section, Creating an Instance of an XMLHTTPRequest Object) creates an instance of an XMLHTTP request object. If the browser does not support the XMLHTTP object, the XmlHttp variable will be set to null and the AJAX code will not be executed. If the browser supports the XMLHTTP object, an asynchronous request is submitted to the server using the XMLHTTP object.
  3. The onreadystatechange property of the XMLHTTP object is used to set the response handler for the asynchronous request. This response handler gets called for every change of readyState property of the XMLHTTP object. In our code we set the HandleResponse function as the response handler.
  4. The open method is called to initialize the request. The first parameter of the open method takes a method definition (GET, POST, etc.), in our case it’s GET. The second parameter takes the request URL. The third parameter takes a Boolean value indicating whether the request submitted is synchronous or asynchronous. In our sample it’s asynchronous, so the third parameter is set to true. Other parameters are optional; we do not use them in our application.
  5. The send method submits the request to the server. The send method's behavior is determined by the third parameter of the open method. In our case it is true, so the send function behaves as an asynchronous function, which means that the browser calls the send function and does not wait for the response to come back from the server.

Listing 5 – CountryListOnChange Function

function CountryListOnChange() 
{
    var countryList = document.getElementById("countryList");
    var selectedCountry = countryList.options[countryList.selectedIndex].value;
    var requestUrl = AjaxServerPageName + "?SelectedCountry=" 
                     + encodeURIComponent(selectedCountry);
    CreateXmlHttp();
    if(XmlHttp)
    {
        XmlHttp.onreadystatechange = HandleResponse;
        XmlHttp.open("GET", requestUrl,  true);
        XmlHttp.send(null);           
    }
}

When the response comes back from the server, the HandleResponse function (Listing 6) gets called. In fact, the HandleResponse function is called for every change of the readyState property of the XMLHTTP object. The readyState property can take a value from 0 to 4 (0=UNINITIALIZED, 1=LOADING, 2=LOADED, 3=INTERACTIVE, 4=COMPLETED). A value of 4 (i.e., COMPLETED) means that receiving the response from the server is completed and the response data is available through properties of the XMLHTTP object. For the readyState property to reach the value of 4, this property changes the value four times (i.e., from LOADING to COMPLETED), so the HandleResponse function gets called four times for each response. To make sure that the data is available in the XMLHTTP object, the XmlHttp.readyState property is compared to the value of 4 in the HandleResponse function (Listing 6).

If the readyState of the XMLHTTP instance has a value of 4, we then need to check its status property to make sure that a valid response was received. The status property holds the HTTP status code returned from the server. A value of 200 means that data received in the request is OK. Some of the other popular HTTP status codes, with which most developers are familiar, are 404 (page not found), 403 (access forbidden), and 500 (internal server error). We check that the XmlHttp.status property is 200 to make sure that the response received has a status of OK. The responseXML property of the XMLHTTP object returns an XML document. This property is useful only when the response from the server is in XML format. In our sample, the response is a list of states in XML format. If both conditions are satisfied (readyState is 4 and status is 200), we call the function ClearAndSetStateListItems with the XML document as an input parameter.

Listing 6 – HandleResponse Function

function HandleResponse()
{
    if(XmlHttp.readyState == 4)
    {
        if(XmlHttp.status == 200)
        {
            ClearAndSetStateListItems(XmlHttp.responseXML.documentElement);
        }
        else
        {
            alert("There was a problem retrieving data from the server." );
        }
    }
}

The function ClearAndSetStateListItems clears the items in the State DropDownList and populates this drop-down list with the new states list by traversing through the XML document supplied as input.

AjaxServer Page

The AjaxServer.aspx file will handle the request sent by the client-side JavaScript using the XMLHTTPRequest object. This page does not have any GUI elements. Listing 7 shows the Page_Load event handler of the AjaxServer.aspx page. This method gets the selected country name from the query string, retrieves the state names as an XML document, and then writes the XML document into the response object.

Listing 7 – Page_Load Method of the AjaxServer.aspx Page

private void Page_Load(object sender, System.EventArgs e)
{
    if(!IsPostBack )
    {
        string selectedCountry = Request["SelectedCountry"];
        if(selectedCountry.Length > 0)
        {
            Response.Clear();
            CountryStateXml countryStateXml = new CountryStateXml();
            string statesString = countryStateXml.GetStatesXMLString(selectedCountry);
            Response.Clear();
            Response.ContentType ="text/xml";
            Response.Write(statesString);
            Response.End();
        }
        else
        {
            //clears the response written into the buffer and end the response.
            Response.Clear();
            Response.End();
        }
    }
    else
    {
        //clears the response written into the buffer and end the response.
        Response.Clear();
        Response.End();
    }
}

Running Sample Code

After downloading the sample application as a Zip file, extract its contents to your wwwroot directory. Create a virtual directory in IIS with the name AjaxSample, and map it to the extracted AjaxSample folder. Using Visual Studio, open the AjaxSample.sln file and press F5 to run the application.

Conclusion

In this article we have shown that AJAX is a technology that employs JavaScript to initiate an asynchronous request to the server, and to handle an XML response from the server. We then created a sample ASP.NET application that uses AJAX to dynamically re-populate a drop-down list without requiring the form to post back to the server. In this way, we have illustrated that AJAX allows an ASP.NET web page to provide for a more responsive user interface.

References

  1. AJAX: A New Approach to Web Applications
  2. AJAX: From Wikipedia, the free encyclopedia
  3. XMLHTTP : From Wikipedia, the free encyclopedia

Thanks

I would like to provide my sincere thanks to my friend, Sanjay Patnaik, for helping me all through this article.


Article Feedback

Title:  
Name:  
Url: ( Optional )
Comment:  
Please add 5 and 1 and type the answer here:

User Comments

<
Title: Help   
Name: Sunil
Date: 11/29/2008 10:31:41 AM
Comment:
I am using AJAX. I have two upadtepanels. I have actually copied the code from net in which the panels can be upadted individually and together also.

But when I execute all the panels gets updated. Is it because I am running it on my localhost????

please reply me soon.
Title: Ajax usage   
Name: pulkit ojha
Date: 11/17/2008 8:45:08 AM
Comment:
i have a list box on a asp page and i want to dynamically read values from database and populate the listbox.

can anyone HELP !!!!!!!!
Title: getting information from the dropdownlist   
Name: Gmoney
Date: 10/31/2008 2:15:02 PM
Comment:
I have a website that works well with AJAX. The only problem is that when I try to retrive the selected item's value from the dropdownlist I populated, It tells the me text and the selected value are "" It also tells me that the selectedindex = -1. How do I get ASP.NET(vb) to get that value I selected?
Title: Error - No overload for method Load takes 2 arguments   
Name: Tommy
Date: 10/29/2008 11:47:49 AM
Comment:
I had to convert the Sample Code to the 2005 version upon opening the solution. After the conversion, I got an error saying "No overload for method "Load" takes 2 arguments. This is where the error occurs, it's inside the GetStatesXMLString method in the CountryStateXML.cs file.
transformToCountryNode.Load(new XPathDocument(HttpContext.Current.Server.MapPath("~/xmlxsl/CountriesAndStates.xsl")).CreateNavigator(), new XmlUrlResolver());

Does anyone know how to resolve this? Thanks a lot.
Great article.
Title: Ajax Learning   
Name: Anil Kumar
Date: 10/22/2008 2:46:17 AM
Comment:
I need the Ajax sample code used in the jsp for dropdown list selection values to oracle databse(using JDBC). Also the entire code should be in a single jsp. So, please send to a_goud@rediffmail.com . Do it ASAP.
Title: Ajax   
Name: Archana
Date: 10/18/2008 8:28:30 AM
Comment:
Hello Ram Prasad.First time I am learning Ajax through ur Article.Now I have idea about Ajax.Can u please send me the CountryStateXml file to my Mail.ganesan.archana@gmail.com
Thank You.
Title: Ajax   
Name: Sarwa
Date: 10/15/2008 3:15:10 AM
Comment:
Hi RamPrasad, This article is really awesome. Before reading this article I was not clear about Ajax. Now I have good understanding about Ajax. Thanks alot.
Title: Populating a DropDownList using AJAX and ASP.NET   
Name: Sandeep Ramani
Date: 10/8/2008 10:26:58 AM
Comment:
This is really good article to understand ajax call to the server..
Title: Populating a DropDownList using AJAX and ASP.NET   
Name: Bhumika
Date: 10/7/2008 8:55:32 AM
Comment:
Really Good
Title: ajax with asp.net   
Name: ajax
Date: 9/25/2008 6:33:47 AM
Comment:
very nice article
Title: CountryStateXml   
Name: Gajendran
Date: 9/22/2008 10:18:24 AM
Comment:
your presentation is fine pls send me the CountryStateXml file to gajendhran@gmail.com
Title: ajax   
Name: aa
Date: 9/22/2008 9:13:05 AM
Comment:
I need a sample code for dropdownlist control. if we select a data from dropdownlist it will post back. I want to use ajax for that. Please send me the code to this id

yogesh.badhan@telescient.com
Title: Need help   
Name: Erisa
Date: 9/17/2008 5:01:16 AM
Comment:
Hi,
I haven't used Ajax before, and I read your article carefully. I then tried to implement and adapt this code for two dropdown lists in my ASP.net project. I do all the steps as mentioned here, i don't get any error but onchange of the countries dropdown list, CountryListOnChange() isn't fired. I think that i have to take some further steps before using Ajax, like downloading some kind of framework or adding a dll, or some king of script in my aspx page or in my web.config file, but i'm not clear how to proceed. Please could you send me an email in this address: erisa85d@gmail.com. I would really really appreciate it.
Thanks in advance,
Erisa
Title: Nice Article   
Name: Parag Mishra
Date: 9/4/2008 1:44:51 PM
Comment:
Hi Ramprasad, the article based on ajax is very nice as i am a beginner in ajax and tried out some examples with the updatepanel and updateprogress and timer before, but seeing this example for which I was on the lookup for, I got the idea from you. Thanks.......if you have other more examples then do kindly please mail me up on my id:- parag.mishra@emerson.com
Title: where it's sample ode   
Name: sudheer
Date: 8/4/2008 2:38:43 PM
Comment:
hi where it's sample code located.I mean where is that zip file located
Title: Very Nice Articles   
Name: Mohammad Javed from Comm-IT India (P) Ltd.
Date: 8/2/2008 3:26:49 AM
Comment:
very nice and easy to understand for every one..
Title: Good Work   
Name: khushbu Desai
Date: 7/31/2008 5:29:20 AM
Comment:
From this only i can understand basic of Ajax.it is really good and help to start on ajax
Title: good   
Name: ketan
Date: 7/30/2008 1:34:14 AM
Comment:
good one
Title: santhosh   
Name: suba
Date: 7/21/2008 9:36:09 AM
Comment:
I saw this article is very useful. I want to learn ajax. I need a sample code for dropdownlist control. if we select a data from dropdownlist it will post back. I want to use ajax for that. Please send me the code to this id mk.subahnanthini@gmail.com
Title: About this article   
Name: jen
Date: 7/12/2008 12:38:10 AM
Comment:
There are MUCH simpler way to do this.
JSON Web Services ScriptManagerProxy.
What he is doing is overkill for ajax.
Dont think it is FOR BEGINNER.
IT CONFUSES BEGINNER EVEN MORE.
Title: Lalit Singh   
Name: Lalit Singh
Date: 7/4/2008 3:32:52 AM
Comment:
nice article ..with these atleast basic knowledge of ajax can be acquired.
Title: Superb Ajax article   
Name: Mohammad Javed
Date: 7/2/2008 6:08:29 AM
Comment:
I want to learn ajax with your team i know asp.net i have small idea of ajax,i knew little bit of javascript,,
please help me,i want to become a ajax programmer, in this article i saw first time so i didn't know how to download the exe files,please help me,then can u sent small application using ajax in my knowledge level please send mail to my id pramanathan_mca@yahoo.co.in and pramanathanmca@gmail.com,
Waiting for your reply,
Title: Excellent Articles   
Name: Mohammad Javed
Date: 7/2/2008 6:07:22 AM
Comment:
I found the article useful and the source code too, but i found it's not working unless i refresh the page once after it gets loaded for the first time.
Can any body advice on this?
Title: help   
Name: Ramanathan
Date: 6/29/2008 2:16:13 PM
Comment:
Hi,
I want to learn ajax with your team i know asp.net i have small idea of ajax,i knew little bit of javascript,,
please help me,i want to become a ajax programmer, in this article i saw first time so i didn't know how to download the exe files,please help me,then can u sent small application using ajax in my knowledge level please send mail to my id pramanathan_mca@yahoo.co.in and pramanathanmca@gmail.com,
Waiting for your reply,

Thanks and Regards,
Your junior Ram..
Title: Check article   
Name: Rama
Date: 6/29/2008 1:50:27 PM
Comment:
nice sample
Title: Excellent example   
Name: Chethan M
Date: 6/28/2008 7:55:56 AM
Comment:
Great!! Really cool example.
Thnaks a lot
Title: Very Simple and Effective   
Name: Nelson Praveen.A
Date: 6/27/2008 1:10:17 AM
Comment:
Crystal clear in design and concepts.
Title: Superb Ajax article   
Name: Anand
Date: 6/25/2008 6:46:40 AM
Comment:
Its simple and clear article.. very useful for beginners..

thanks buddy.
Title: Its simple and good article   
Name: Lintu
Date: 6/10/2008 8:21:30 AM
Comment:
Its simple and good article
Title: Simple Example and very good one.   
Name: Timmy
Date: 6/10/2008 8:04:11 AM
Comment:
This very helpful for beginners who are new to Ajax.
Title: RE: Wow..   
Name: American
Date: 6/5/2008 1:38:47 PM
Comment:
I'm from the USA, and I use this site.
Title: After postback value lost.   
Name: Kannappan
Date: 6/5/2008 8:27:22 AM
Comment:
Hi,

I am filling the dropdown using above method but after the server event happens the filled value lost. Please provide me the solution.
Title: Very Good Exmple of AJAX   
Name: Gaurav Sharma
Date: 6/4/2008 2:15:40 AM
Comment:
Nice & helpful example
Title: Shiji   
Name: Shiji
Date: 6/2/2008 9:14:51 AM
Comment:
Good one
Title: lalitsingh   
Name: lalit kumar singh
Date: 5/31/2008 6:28:38 AM
Comment:
very nice article
Title: a   
Name: a
Date: 5/28/2008 4:14:36 PM
Comment:
Interesting
Title: Nice way to define Ajax   
Name: Aaryan
Date: 5/28/2008 5:21:00 AM
Comment:
Nice way to define Ajax
Title: Very Good Exmple of AJAX   
Name: Gaurav
Date: 5/18/2008 2:10:48 AM
Comment:
This is very straight forward example of AJAX to populate dropdownlist control and to perform very basic action on two dropdownlist controls.
I like it.
Thanks
Title: NICEEE   
Name: Shiras
Date: 5/15/2008 2:47:32 PM
Comment:
Nice article
Title: Ajax Sample   
Name: sha
Date: 5/15/2008 6:14:26 AM
Comment:
Nice Example for AJAX learner............

thnx
Title: Not working unless i refresh the page once   
Name: Istiaq
Date: 5/12/2008 12:59:38 AM
Comment:
Hi,
I found the article useful and the source code too, but i found it's not working unless i refresh the page once after it gets loaded for the first time.
Can any body advice on this?
Title: Hai   
Name: Abhishek
Date: 5/2/2008 6:13:47 AM
Comment:
Nice example
Title: fghgfhf   
Name: fghfh
Date: 5/2/2008 1:09:59 AM
Comment:
nvnvnv
Title: Superp Article   
Name: Ilayaraja
Date: 5/2/2008 12:58:55 AM
Comment:
This article is good.
Title: simple and nice   
Name: AB
Date: 5/1/2008 3:29:05 AM
Comment:
nice and clear
Title: AJAX and JAVA script problem   
Name: Developer
Date: 4/25/2008 12:31:02 AM
Comment:
Populating the dropdown using AJAX (XMLHTTP)is working well in my Web page but in the same page i have a link (Link Button).On click of the link button a confirm box pops up .If OK is clicked it redirects to anohter page.This works fine in all other page but in AJAX page alone the control is not going into server side event.It throws up "Invalid Syntax" in status bar.Please help as i am new to AJAX
Title: AJAX   
Name: ANIL
Date: 4/17/2008 7:13:59 AM
Comment:
hi
write now i am developing a web application in which i have to populate two dropdownlist
for example i want to populate first dropdownlist with country list and if we select any country from 1st dropdownlist then it should place all the states in the second dropdownlist and if we select any state from the second dropdownlist then it should give the capitals in the textbox beside that
please solve my problem its very urgent
you can mail me at aniljadhav15@rediffmail.com
Title: sdf   
Name: sdf
Date: 4/15/2008 1:00:46 PM
Comment:
adf
Title: hgjyhj   
Name: ffgfgf
Date: 4/15/2008 10:30:10 AM
Comment:
sfrfd
Title: shoaibkh   
Name: shoaib
Date: 4/9/2008 2:34:24 PM
Comment:
I really want to learn ajax for implementing it in a .net
Title: dropdown list   
Name: anu
Date: 4/4/2008 5:51:30 AM
Comment:
database retrive the value of dropdown list is selected the item display the another text box
Title: Give more easier method   
Name: Biswanath
Date: 3/31/2008 12:03:00 AM
Comment:
Give more easier method using javascript.
This is waste really becoz we don't have time to
put all state & corresponding cities. So make it more user
friendly by adding JS.
Title: dropdown   
Name: Sathish
Date: 3/26/2008 12:24:48 AM
Comment:
the value selecting on dropdownlist, should dispaly in pariticular textbox.. pls give the coding
Title: Props   
Name: newbie2vb.net
Date: 3/15/2008 3:19:43 PM
Comment:
Great article. Great example
Title: good one   
Name: kathu
Date: 3/11/2008 5:59:17 AM
Comment:
this is actally a good example...
Title: nice one   
Name: mike
Date: 3/6/2008 12:36:06 PM
Comment:
good example
Title: ajax   
Name: sukhdeep
Date: 3/2/2008 2:04:50 AM
Comment:
nice article it helps very much in my project
Title: good   
Name: cheten
Date: 2/26/2008 5:11:03 AM
Comment:
hi
this is nice article about ajax control.
Title: Thanking   
Name: Nethaji
Date: 2/21/2008 8:38:09 AM
Comment:
Its Excellently working , Realy its very useful for me,
I need to display the value from database using dropdown
Title: First time i like very much   
Name: pavan kumar
Date: 2/21/2008 4:00:27 AM
Comment:
this sample application is very nice.is is given by very clearly.thank u a lot.pls keep doing like this
Title: Interesting   
Name: Adam
Date: 2/17/2008 9:37:18 AM
Comment:
nice to learn ajax but I wanted it in VB language and not C.
Title: About Modal Popup   
Name: abhay
Date: 2/15/2008 7:32:37 AM
Comment:
hi
i m using modal popup. when my popup open, and click on ok then i want to go on next page. pls send code urgent.
Title: no words to say   
Name: allen
Date: 2/15/2008 6:53:00 AM
Comment:
this article was published in 2005, but i find it in 2008.
so bad
Title: great   
Name: Manish
Date: 2/14/2008 9:05:54 AM
Comment:
thanks man, for guiding on AJAX , nice
Title: nice   
Name: Puja
Date: 2/6/2008 4:44:43 AM
Comment:
nice article
puja
http://mindgrillq.blogspot.com
http://www.shopperixmall.com
Title: Good Example   
Name: Nitin Tiwari
Date: 1/21/2008 8:15:27 AM
Comment:
ya...really,,it is best example..h t
Title: Studing Ajay   
Name: Indravijay
Date: 1/9/2008 2:23:19 AM
Comment:
i was just learning how i will create my first Ajax Test page... this example make me understand of basic working of ajax... this is eraly good Approch for making new comer to learn new
Title: AJAX With ASP.NET   
Name: sekar.j
Date: 1/7/2008 7:54:16 AM
Comment:
thank u i learn more technique for ur book
Title: AJAX   
Name: Vipul
Date: 1/6/2008 1:37:30 PM
Comment:
good topic to understand AJAX technology
Title: asp.net with c#   
Name: karthick
Date: 1/2/2008 6:27:57 AM
Comment:
i want to know how to retrieve particular datafield from database using dropdownlist box pls urgent give me coding
Title: dropdownlist   
Name: arun
Date: 12/28/2007 7:45:10 AM
Comment:
plz tell me the codings.... if a item in dropdownlist is clicked another item in db should display in another dropdownlist in asp.net
Title: dropdownlist   
Name: chand
Date: 12/28/2007 7:43:40 AM
Comment:
if a item in dropdownlist is clicked another item in db should display in another dropdownlist in asp.net
Title: Pupulate two dropdown list   
Name: nitikeni
Date: 12/17/2007 4:42:00 AM
Comment:
I'm very charmed with it.
this is very cool, very handy for those guys whoever new in the ajax world.

it's very managed and understandable.keep posting that kind of sample which give some idea to learn AJAX.
Title: Pupulate two dropdown list   
Name: Avinash Pohane
Date: 12/7/2007 6:58:57 AM
Comment:
This article is in simplified way and handy.Thnk u very much.Please post more articles related to AJAX with ASP.NET which should come across in real time.Please provide full code in the tutorial.
Title: populate two dropdownlist   
Name: raghu
Date: 11/29/2007 6:43:22 AM
Comment:
hi
write now i am developing a web application in which i have to populate two dropdownlist
for example i want to populate first dropdownlist with country list and if we select any country from 1st dropdownlist then it should place all the states in the second dropdownlist and if we select any state from the second dropdownlist then it should give the capitals in the textbox beside that
please solve my problem its very urgent
you can mail me at p.raghu@yahoo.co.in
Title: using ajax in asp.net 2.0   
Name: sandeep sindwani
Date: 11/26/2007 4:27:47 AM
Comment:
currently m learning asp.net,ajax and xml. so please send me more and more samples and code of this subject.

my emailid is-sandeep_mca22@yahoo.co.in
Title: I could not get xmlhttp object   
Name: Joseph
Date: 11/16/2007 6:44:35 AM
Comment:
hpw to get the xmlhttp object and give me the and ClearAndSetStateListItems()
Title: Bind DataGrid   
Name: manuj
Date: 11/13/2007 11:33:48 PM
Comment:
How can i bind datagrid using xmlhttp object and web service.
Web method returns dataset.
Title: Populating a textbox   
Name: sara
Date: 11/5/2007 7:44:11 AM
Comment:
I am selecting one of the option from combo box n i want to show that selected value in text box using asp/vbscript.
I am not getting the property of select tag of html so tht i can read the value of combo box
My mail id is saraswati.panchakshari@gmail.com
Title: My mail ID   
Name: Archana Pataskar
Date: 10/29/2007 7:15:37 AM
Comment:
HI,
Here is my mail id:- archanapataskar@gmail.com. You can answer me on above ID.
Title: Regarding the XPathDocument   
Name: Archana Pataskar
Date: 10/29/2007 7:13:29 AM
Comment:
Hi,
I could not understand the use of XPathDocument here. Can't we use XMLDocument instead? Does it really matter? what is the impact of using XPathDocument in this? What is the difference between XPathDocument and XMLDocument?
Title: Populating a textbox   
Name: Eric C.
Date: 10/25/2007 5:22:58 PM
Comment:
I am trying to use a selection of a drop down list to populate the appropriate text fields from a database. The selection is a user and it needs to populate the user's appropriate phone and email fields. I am coding in VB.NET and any suggestions would be appreciated.

My email is: collins101@gmail.com
Title: Wel done   
Name: Archana Pataskar
Date: 10/24/2007 9:25:58 AM
Comment:
Such an interesting and informative topic!
Title: Find Datavalue fiels in dropdown list   
Name: Madhavi DAkhani
Date: 10/23/2007 3:05:08 AM
Comment:
Hello sir,
I am make a datalist and in i have taken one dropdown list and one text area so how to find which dropdown is selected and what is write in text area.
plz give answer thankx in advance.

my email-id is:

madhavidakhani@gmail.com
Title: binding the dropdown without postback   
Name: Yunus
Date: 10/19/2007 2:01:30 AM
Comment:
I am new to ajax pls send me the code to use ajax in binding the dropdown so that without postback occurs
Title: trying to populate listbox from datagrid   
Name: pranathi
Date: 10/18/2007 8:43:59 AM
Comment:
Hi
I am trying to place the checked checkboxes of datagrid to listbox using ajax

plz help me
mail id: pranathi27@yahoo.co.in
Thanks in advance
Title: How to use Ajax to bind the drop-down in asp.net   
Name: sanjeev
Date: 10/16/2007 3:25:56 AM
Comment:
Hi,
Sir I am new to ajax pls send me the code to use ajax in binding the dropdown so that no postback occurs.
Regards
sanjeev
sanjeev_mca1234@rediffmail.com
Title: ramoji999@gmail.com   
Name: ramoji
Date: 10/15/2007 7:26:49 AM
Comment:
Sorry i forgot to give my Email Id :
it is ramoji999@gmail.com
Title: Want a similar example with database   
Name: Ramoji
Date: 10/15/2007 7:00:30 AM
Comment:
Hi
The example was so good, but i have an issue that i need to fetch the data from data base not from xml file my function returns a data table and i need the output of data table as items in child drop down
Pls help me in this ASAP
Title: java   
Name: david
Date: 10/13/2007 4:17:22 PM
Comment:
hai ... i am new to enter java
Title: Como lleno un combo con ajax??   
Name: Javier Rodriguez
Date: 10/11/2007 1:18:01 PM
Comment:
Solo quiero ver un ejemplo de codigo en ASP.NET como llenar un combo con AJAX,Yo Lo puedo hacer con PHP.

Mi Correo es Jaxier.Rod@Gmail.com
Title: plz help me   
Name: Mala
Date: 10/11/2007 1:00:34 AM
Comment:
hello ,

i am using drop down for country , state and city , plz tell me how can i make this in asp.net 2005 using c# by ajax
Title: Help!Help!Help   
Name: Babita
Date: 9/25/2007 6:09:48 AM
Comment:
hello sir,i m very new to AJAX. plz ans this........
How to get state value in my variable which i am using in code behind file ( Ex: string str=selectstate.selecteditem.text; )
how i get value in my local string. plz plz ans this: and one thing which is not yet clear that when we post back the page it's comes in intial mode i mean combo comes in first mode that is india state.
why.......... can u ans me plz......
Plz help. it's very urgent. Thanx in advance
My email address is: babitamca07@gmail.com
Title: akax   
Name: venkat
Date: 9/25/2007 12:30:40 AM
Comment:
Hi
this is very good and simple article about AJAX.But how can i use cache to a textbox as like in google.
if we enter text in textbox it will display all rellated which had been typed by user in previous
Title: BRAVO   
Name: Sachin Dubey
Date: 9/24/2007 3:30:13 AM
Comment:
Hi
this is very good and simple article about AJAX.But how can i use cache to a textbox as like in google.
if we enter text in textbox it will display all rellated which had been typed by user in previous
Title: ajax   
Name: Pawan
Date: 9/21/2007 7:41:08 PM
Comment:
Thanks for using ajax.......
Title: Bind Second Drop Down from Database on change of first one   
Name: ssrconstantine
Date: 8/31/2007 11:16:55 AM
Comment:
this is nice article but i want to bind Second DropDown from selected value of first drop down not from XML.
Title: Thanks   
Name: Aravind B.s
Date: 8/30/2007 8:23:53 AM
Comment:
Hi
this is very good and simple article about AJAX.But how can i use cache to a textbox as like in google.
if we enter text in textbox it will display all rellated which had been typed by user in previous.

arv_bs@yahoo.co.in
Title: Thanks   
Name: narendrasinh
Date: 8/29/2007 8:15:30 AM
Comment:
this is vary god and help ful to us so ones more thanks again and
Title: Problem with View state   
Name: Murali Dharan
Date: 8/23/2007 9:07:37 AM
Comment:
Hi,
This post is really good...I have a doubt.When you bind the data into the drop down list in client side and if we are posting the page back to the server say by a click of a button then the Selected value of the particular Drop down list can't be captured.Is there any way to capture the value of the ddl's selected data
Title: Mr   
Name: Mohammad
Date: 8/19/2007 1:19:50 PM
Comment:
Very wel done Ramaprasad. This the best artical i ever come across. Keep up the good work.
Title: ajax tutorial   
Name: ganesh shankar
Date: 8/13/2007 5:01:51 AM
Comment:
very fine topic
Title: Best article   
Name: Rajeev kumar
Date: 8/8/2007 2:25:36 AM
Comment:
This is best article.
Thanls a lot
Rajeev
Title: excelent article   
Name: sairam sadanala
Date: 8/2/2007 6:23:52 AM
Comment:
nice one
Title: sanjay   
Name: good work
Date: 7/25/2007 11:52:05 PM
Comment:
I am not too sure how to instantiate the XML in this case? Coz i dont see it as a class? Could someone help?
Title: CountryStateXml class   
Name: Gene Rajska
Date: 7/25/2007 2:40:00 PM
Comment:
To sandeep.

If you download the code sample, you will find the class.
The program works if you open it using a browser.
The problem is how to increase the dropdownlist from two to three or four.

Gene.
Title: the CountryStateXml class is not mentioned anywhere   
Name: sandeep
Date: 7/24/2007 7:12:46 AM
Comment:
the CountryStateXml class is not defined anywhere and the methods used in it are also not defined anywhere....
Title: BEST I HAV SEEN ...THANX ALOTTT!!!   
Name: sandeep
Date: 7/23/2007 8:30:24 AM
Comment:
hey my sincere thanx to for posting this article to Mr.ramaprasad potturi & Mr.Sanjay Patnaik
Title: Web Developer   
Name: Gene Rajska
Date: 7/17/2007 10:42:16 AM
Comment:
Is it possible to have 4 dropdownlists? 1 for world regions, 1 for country list or each region, 1 for state lists for each country and 1 for cities for each state.
If there are no states, then the country becomes the state. And some states have only 1 city, like Singapore and Vatican.
Anybody who can do it may email me at rajska7@gmail.com.
Thanks
Title: very good   
Name: jitendra
Date: 7/17/2007 6:17:39 AM
Comment:
very good
Title: very good   
Name: kumar
Date: 7/11/2007 8:18:54 AM
Comment:
it is good example for beginners
Title: Thanks   
Name: Brijesh Singh
Date: 7/11/2007 1:08:15 AM
Comment:
It is nice example but i want to use ms access table rather than xml file to access the Country and States,then what changes/code i have to make.Can u plz have any....idea.

Brijesh Singh
email:brijesh@cybersoftdesigns.com
Title: Thanks   
Name: Ratnesh kumar Verma
Date: 7/10/2007 9:27:26 AM
Comment:
Nice job i find my solution but one thing which is not yet clear that when we post back the page it's comes in intial mode i mean combo comes in first mode that is india state.
why.......... can u ans me plz......
my Email id is meetratnesh@gmail.com.