日期:2014-05-17 浏览次数:20809 次
function GetData(p) { document.getElementById("HiddenField1").value =data;//data为某个textbox我自己输的值,是变值 document.getElementById("d").innerHTML = "正在读取数据……"; h = window.XMLHttpRequest ? new window.XMLHttpRequest() : new ActiveXObject("MSXML2.XMLHTTP"); h.open("GET", '<%=Request.FilePath %>?id=' + p.value, true); h.onreadystatechange = function () { if (h.readyState == 4) { if (h.status >= 200 && h.status < 300) { document.getElementById("d").innerHTML = h.responseText; } else { document.getElementById("d").innerHTML = "<h2>数据操作错误:</h2>" + h.responseText; } } } h.send(null); }
protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["id"] == "1") { string s = this.HiddenField1.Value;//此处获取的s为空 Response.ClearContent(); GridView1.DataSource = getDataSource(); GridView1.DataBind(); System.Text.StringBuilder sb = new System.Text.StringBuilder(); System.IO.StringWriter sw = new System.IO.StringWriter(sb); HtmlTextWriter htw = new HtmlTextWriter(sw); Literal header = new Literal(); header.Text = "<h2>项目" + Request.QueryString["id"] + "</h2>"; Header.Controls.Add(header); Header.RenderControl(htw); GridView1.RenderControl(htw); Response.Write("这里查询数据,输出结果就可以了。结果:" + sb.ToString()); Response.End(); } }
function GetData(p) { document.getElementById("HiddenField1").value =data;//data为某个textbox我自己输的值,是变值 document.getElementById("d").innerHTML = "正在读取数据……"; h = window.XMLHttpRequest ? new window.XMLHttpRequest() : new ActiveXObject("MSXML2.XMLHTTP"); //要发送给动态页 h.open("GET", '<%=Request.FilePath %>?id=' + p.value+'&HiddenField1'+escape(data), true); h.onreadystatechange = function () { if (h.readyState == 4) { if (h.status >= 200 && h.status < 300) { document.getElementById("d").innerHTML = h.responseText; } else { document.getElementById("d").innerHTML = "<h2>数据操作错误:</h2>" + h.responseText; } } } h.send(null); }