ASP.NET brings us a programming mechanism for event models, which makes we put all the tasks on the server, which is a small change, in fact, this is not a problem, but we can't stand it, if we Changing the content page in an input box To refresh, change the DROPDOWNLIST selection requires that another DropDownList needs to be refreshed, it is really depressed.
Below I will describe an original method, which is why it is because this approach is already before asp.net, I don't have to describe the relationship between these two, we have to say today. How do you not refresh the page to update DropDownList, which is designed to throw bricks. In fact, use this method to achieve many applications that do not refresh the webpage and the background interaction. If you don't say anything, look at our example, first we need one Place two DROPDOWNLIST pages, if it is called WebForm2.aspx, the code of the page is as follows:
<% @ Page language = "c #" codebehind = "Webform2.aspx.cs" autoeventwireup = "false" inherits = "WebAppTest1.webform2"%>
Function load (state) {
VAR DRP2 = Document.GtelementByid ("DropdownList2");
For (var i = 0; i <= drp2.options.length -1; i ) {
Drp2.remove (i);
}
VAR OHTTPREQ = New ActiveXObject ("msxml2.xmlhttp");
VAR ODOC = New ActiveXObject ("msxml2.domdocument");
OHTTPREQ.OPEN ("post", "Webform6.aspx? state =" state, false);
OhttpReq.send ("");
Result = OHTTPREQ.RESPONSETEXT;
ODoc.LoadXml (Result);
Items = odoc.selectnodes ("// city / table");
For (VAR item = items.nextNode (); item; item = item.nextNode ()) {var city = item.selectsinglenode ("// city"). NodetyPedValue;
VAR newOption = document.createElement ("option");
NEWOPTION.TEXT = City;
NEWOPTION.VALUE = City;
Drp2.Options.add (newoption);
}
}
script>
HEAD>