//HTTP传递读取数据
前台
//初始化HTTP對象
function GetXmlHttpRequest()
{
var A=null;
try
{
A=new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e)
{
try
{
A=new ActiveXObject("Microsoft.XMLHTTP");
}
catch(oc)
{
A=null;
}
}
if(!A && typeof XMLHttpRequest != "undefined")
{
A=new XMLHttpRequest();
}
return A;
}
//用HTTP方式绑定下拉框
function GetHTTP()
{
document.getElementById("dpHttp").options.length=0;
var xmlhttp = GetXmlHttpRequest();
var weburl="Default.aspx?senderCtl=Http_string";
xmlhttp.open("Post",weburl,false);
xmlhttp.send("");
var returns=xmlhttp.responseText;
if(returns!=""&&returns!=null)
{
var tempxmlRtn=returns.replace('<ID>','').replace('</ID>','');
var arrayList =tempxmlRtn.split("**");
var arrayValue =new Array();
for(i=0;i<arrayList.length;i++)
{
arrayValue=arrayList[i].split("##");
document.getElementById("dpHttp").options[i+1]=new Option(arrayValue[1],arrayValue[0]);
arrayValue[0]="";arrayValue[1]="";
}
document.getElementById("dpHttp").options[0]=new Option("","");
document.getElementById("dpHttp").value="";
}
}
//后台
private string GetHttp_string()
{
string strValue = "<ID>";
string strLink = "";
DataTable Http_dt = this.Setdt();
for(int i=0;i<Http_dt.Rows.Count;i++)
{
strValue += strLink;
strValue += Http_dt.Rows[i]["ID"] .ToString()+ "##";
strValue+= Http_dt.Rows[i]["VALUE"].ToString();
strLink = "**";
}
strValue += "</ID>";
Response.Write(strValue );
Response.Flush();
Response.Close();
}