日期:2014-05-20 浏览次数:20452 次
var xmlhttp; function GetData() { var time=document.getElementById("<%=TimeTB.ClientID%>").value; var scity=document.getElementById("<%=SCityTB.ClientID%>").value; var dcity=document.getElementById("<%=DCityBT.ClientID%>").value; if(window.ActiveXObject) { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");//IE浏览器 } else if(window.XMLHttpRequest)//非IE浏览器 { xmlhttp=new XMLHttpRequest(); } else { alert("创建XMLHttpRequest对象失败!"); return; } xmlhttp.Open("GET","GetSelectData.aspx?stime="+time+"&scity="+scity+"&dcity="+dcity,false); xmlhttp.onreadystatechange=handlfunc; xmlhttp.send(null); } function handlfunc()//获取数据后处理函数 { if(xmlhttp.readystate==4) { if(xmlhttp.status==200) { var data=bytes2BSTR(xmlhttp.ResponseBody); var start=data.indexOf("查找结果"); var end=data.indexOf("结束"); var finaldata=data.substring(start+8,end); document.write(xmlhttp.ResponseText); //document.getElementById('data_div').innerHTML=data; //document.getElementById("data_div").innerHTML=xmlhttp.ResponseText; } }
protected void Page_Load(object sender, EventArgs e) { string time = "2009-08-05",scity="南昌",dcity="景德镇"; if (!IsPostBack) { try { time = Request.QueryString["stime"].ToString(); scity = Request.QueryString["scity"].ToString(); dcity = Request.QueryString["dcity"].ToString(); } catch (Exception ex) { Response.Redirect("ErrorPage.htm"); } LoadData(time, scity, dcity); } } public void LoadData(string time,string scity,string dcity) { SqlParameter[] sp ={DBAccess.MakeParam("@stime",SqlDbType.VarChar,time), DBAccess.MakeParam("@scity",SqlDbType.VarChar,scity), DBAccess.MakeParam("@spoint",SqlDbType.VarChar,""), DBAccess.MakeParam("@dcity",SqlDbType.VarChar,dcity), DBAccess.MakeParam("@dpoint",SqlDbType.VarChar,"") }; int flag = 0; DataView dv = DBAccess.GetData("qiche_SelectBusInfo", sp, out flag).Tables[0].DefaultView; if (flag == 11) { Response.Redirect("ErrorPage.htm"); } this.DataList1.DataSource = dv; this.DataList1.DataBind(); }
protected override void Render(HtmlTextWriter writer) { HtmlTextWriter gridWriter = new HtmlTextWriter(new System.IO.StringWriter()); DataList1.RenderControl(gridWriter); //给ajax返回数据 Response.Write(gridWriter.InnerWriter.ToString()); } public override void VerifyRenderingInServerForm(System.Web.UI.Control control) { }
------解决方案--------------------