/// <summary> /// This function populates data into country and state combo box. /// </summary> private void Page_Load(object sender, System.EventArgs e) { CountryStateXml countryStateXml = new CountryStateXml(); //Getting the list of countries in an ArrayList ArrayList countries = countryStateXml.GetCountryList(); //Populating country combo box for(int index = 0; index < countries.Count; index++) { countryList.Items.Add(countries[index].ToString()); } //Getting the list of states for a given in an ArrayList ArrayList states = countryStateXml.GetStateList(countries[0].ToString()) ; //Populating states combo box for(int index = 0; index < states.Count; index++) { stateList.Items.Add(states[index].ToString()); } }
//Sends the response back, with XML data. 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(); //For a given country, getting country and states under that country in XML format. string statesString = countryStateXml.GetStatesXMLString(selectedCountry); Response.Clear(); Response.ContentType ="text/xml"; Response.Write(statesString); //end the response 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(); } }