<script language="javascript"> function load(state) { var drp2 = document.getElementById("SearchType1"); while(drp2.length!=0) { drp2.remove(0); } var oHttpReq = new ActiveXObject("MSXML2.XMLHTTP"); //发送请求 var oDoc = new ActiveXObject("MSXML2.DOMDocument"); //响应结果 var state=document.getElementById("SearchType"); oHttpReq.open("post","temp.aspx?state="+state.options[state.selectedIndex].value,false); oHttpReq.send(""); result = oHttpReq.responseText; oDoc.loadXML(result); // items = oDoc.selectNodes("//CITY/Table"); var items = oDoc.selectNodes("//NewDataSet/type"); for (var item = items.nextNode();item;item = items.nextNode()) { var city = item.selectSingleNode("name").nodeTypedValue; var newOption = document.createElement("OPTION"); newOption.text = city; newOption.value = city; drp2.options.add(newOption); } </script>
|
SearchType.Attributes.Add("onchange", "load()");
|
这里要注意的是中文传递:首先在Webconfig里面加上下面一句
<globalization requestEncoding="utf-8" responseEncoding="utf-8" culture="zh-CN" uiCulture="zh-CN"/>
|
接着在temp.aspx里面加下下面一句
Encoding gb2312 = Encoding.GetEncoding("gb2312"); Request.ContentEncoding = gb2312;
|
在这个空间里面using System.Text;
OleDbCommand cmd = new OleDbCommand("select name from Type", con); OleDbDataAdapter oda = new OleDbDataAdapter(); oda.SelectCommand = cmd; DataSet ds = new DataSet(); oda.Fill(ds, "type"); XmlTextWriter writer = new XmlTextWriter(Response.OutputStream, Response.ContentEncoding); writer.Formatting = Formatting.Indented; writer.Indentation = 4; writer.IndentChar = ' '; ds.WriteXml(writer); writer.Flush(); Response.End(); writer.Close();
|
阅读(835) | 评论(1) | 转发(0) |