每隔10秒调用一次页面加载事件. [英] Call page load event after every 10 seconds.

查看:81
本文介绍了每隔10秒调用一次页面加载事件.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一种在每5秒钟或10秒钟后调用加载事件的情况,有人会帮助我.

i''m having a scenario to call load event after every 5 seconds or 10 seconds some one help me.

推荐答案

您可以使用计时器类并进行设置将属性的tick属性设置为5000
you can use timer class and set tick property to 5000


有多种方法可以在一定时间间隔后自动刷新页面.

方法1 :
在开头部分使用META tag:元刷新标签 [
There are various ways to refresh page automatically after certain interval of time.

Method #1:
Using META tag in head section: Meta Refresh Tag[^]
Sample:
<meta http-equiv="Refresh" content="10;URL=http://www.yourURL.com"></meta>



您也可以从代码后面附加元标记:



You can append meta tag from code behind too:

Response.AppendHeader("Refresh", "10; URL=http://www.yourURL.com")



方法2 :
使用
计时器控制 [计时器控件 [ ^ ]:
样本;



Method #2:
Using Timer Control[^]: It allow you to do postbacks at certain intervals: Timer control[^]:
Sample;

<asp:Timer runat="server" id="UpdateTimer" interval="5000" ontick="UpdateTimer_Tick" />
<asp:UpdatePanel runat="server" id="TimedPanel" updatemode="Conditional">
   <Triggers>
        <asp:AsyncPostBackTrigger controlid="UpdateTimer" eventname="Tick" />
   </Triggers>
   <ContentTemplate>
        <asp:Label runat="server" id="DateStampLabel" />
   </ContentTemplate>
</asp:UpdatePanel>



方法3 :
在Javascript中使用setTimeout:在一定间隔后自动刷新页面 [ ^ ]
样本:



Method #3:
Using setTimeout in Javascript: Automatically refresh page after some interval[^]
Sample:

function RefreshPage(Period)
{
    setTimeout("location.reload(true);", Period);
}
<body  önload="javaScript:RefreshPage(1000);">



方法4 :
使用Response.AppendHeader方法: MSDN:HttpResponse.AppendHeader方法 [ ^ ]
样本:



Method #4:
Using Response.AppendHeader method: MSDN: HttpResponse.AppendHeader Method[^]
Sample:

// Page refresh is set to 5 seconds after the client session timeout setting specified in the web.config file.
this.Response.AppendHeader("Refresh",Convert.ToString(Session.Timeout * 60 + 5));



选择适合您的一个.



Pick one that suits you.


这篇关于每隔10秒调用一次页面加载事件.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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