如何在asp.net页面中设置基于时间的页面加载? [英] How to Set Time Based Page Load in asp.net page?

查看:63
本文介绍了如何在asp.net页面中设置基于时间的页面加载?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!

我有一个GridView,它将显示绑定到GridView的数据库表XXXXX中的10条记录.当用户在浏览器中查看页面时,表XXXXX中又添加了5条记录,因此该表现在包含15条记录.显示GridView的页面应以这样的方式进行编程,例如在经过15秒的时间间隔后刷新GridView(或整个页面).

如何做到这一点?有人知道吗,请告诉我如何解决这个问题.

感谢您的宝贵时间!

由mohan.

Hi everybody!

I have a GridView which would display the 10 records that are in the database table XXXXX bound to the GridView. While the user is looking at the page in the browser another 5 records have been added to table XXXXX so that it now contains 15 records. The page displaying the GridView should be programmed in such a fashion that the GridView (or maybe the whole page) are refreshed say after an elapsed time interval of 15 seconds.

How can this be achieved? I anyone knows please tell me how to solve this.

Thanks for your time!

by mohan.

推荐答案

<script>
window.setTimeOut(windows.location.href=window.location.href, 5000);
</script>



http://www.w3schools.com/jsref/met_win_settimeout.asp [



http://www.w3schools.com/jsref/met_win_settimeout.asp[^]

<meta http-equiv="refresh" content="600">



http://webdesign.about.com/od/metataglibraries/a/aa080300a.htm [ ^ ]



http://webdesign.about.com/od/metataglibraries/a/aa080300a.htm[^]


为了解决这个问题,必须牢记asp.net页面是一种断开连接的技术.呈现页面并将其交付给浏览器后,就可以了...页面的内容就不剩了.

但是...客户端仍然可以执行操作.最常见的方法是使用jQuery,但您也可以使用纯JavaScript. javascript将创建一个计时器,该计时器将等待指定的毫秒数,然后刷新页面.如果这是我正在从事的项目,则建议您使用UpdatePanel和Web服务返回数据,以便您不进行整页刷新.

因此,要执行此操作,请按照下列步骤操作:
In order to solve this, you must keep in mind that asp.net pages are a disconnected technology. Once the page is rendered and delivered to the browser, that''s it...nothing of the page is left.

However...the client side is still able to perform operations. The most common method is to use jQuery, but you can also use pure javascript. The javascript would create a timer that will wait the number of designated miliseconds and then do a page refresh. If it was a project I was working on, I would recommend using an UpdatePanel and a web service to return the data so that you''re not doing a full page refresh.

So, to do this, follow these steps:

  1. 创建一个将返回数据表(或可绑定到Gridview的其他对象)的Web服务.
  2. 创建一个调用Web服务的javascript函数
  3. Within页面加载确保将此javascript代码以这样一种方式添加到呈现的HTML中:在将文档加载到浏览器中时执行该代码:setTimeOut("nameOfJavascriptFunction",10000);

  1. Create a webservice that will return a data table (or other object that is bindable to a gridview).
  2. Create a javascript function that calls the webservice
  3. Within the page load Make sure this javascript code gets added into the rendered HTML in such a fashion that it is executed when the document has been loaded into the browser: setTimeOut("nameOfJavascriptFunction", 10000);


这篇关于如何在asp.net页面中设置基于时间的页面加载?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆