当前位置: 代码迷 >> ASP.NET >> 怎么在服务器端 刷新 客户端
  详细解决方案

怎么在服务器端 刷新 客户端

热度:5997   发布时间:2013-02-25 00:00:00.0
如何在服务器端 刷新 客户端 ?
一个页面     有2个文本框(输入查询条件用)。输入查询条件,点击     查询   按钮,   查询结果   装入   DataGrid

我想让DataGrid   的内容   每隔5   秒   自动刷新一次

这个怎么实现?
谢谢

------解决方案--------------------------------------------------------
使用window.setTimeout

setTimeout(window.location.reload(),5000));
------解决方案--------------------------------------------------------
<script type= 'text/javascript '>
var txt=document.getElementById( 'xxxx ');//你的文本框的ID
function refreshPage()
{
window.location= 'xxx.aspx?keyword= '+txt.value;
setTimeout( "refreshPage() ",5000);
}
setTimeout( "refreshPage() ",5000);//执行刷新
//注意下面使用了服务器技术,赋值用的,你也可以在.cs文件中实现
<%
if(Request.QueryString[ "keyword "]!=null&&Request.QueryString[ "keyword "].Trim()!= " ")
Response.Write( "txt.value= "+Request.QueryString[ "keyword "]);
%>
</script>
  相关解决方案