【发布时间】:2015-04-06 19:30:49
【问题描述】:
我对此有点陌生,而且我的英语也很差。无论如何:
如果我的报告中有任何新记录,我正在尝试设置一个刷新我的页面的计时器。显然我的计时器工作正常,因为当我调试它时它进入函数Timer1_Tick,但它不会刷新我的页面。
代码如下:
System.Timers.Timer Timer1 = new System.Timers.Timer();
Timer1.Interval = 10000;
Timer1.Elapsed += Timer1_Tick;
Timer1.Enabled = true;
和
protected void Timer1_Tick(object sender, EventArgs e){
Response.Redirect("ReporteIncidencia.aspx"); //1st attempt
ScriptManager.RegisterStartupScript(Page, typeof(Page), "somekey", "RefreshPage()", true); //2nd attempt
Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "RefreshPage()", true); //3rd attempt
}
还有
<script type="text/javascript">
function RefreshPage()
{
window.location.reload()
}
</script>
编辑:
- 我正在使用 Framework .NET 3.5
- 我试过这个post,但它不起作用。
- 感谢您的回答。
【问题讨论】:
-
您是否考虑过在您的应用程序中使用 SignalR?
-
@rajeemcariazo 我不熟悉 SignalR,我看看谢谢
-
@Izzy 我已经尝试过该帖子,但没有任何效果,谢谢
-
“没有用。”
-
@JasonMArcher 嗨,*Izzy 说我应该看看这篇文章 (stackoverflow.com/questions/2240287/…),但在我在这里发布我的问题之前,我已经尝试了该帖子的答案。这就是为什么我说:“(它)没有任何作用”。我将修改我的问题并发布一些附加代码。谢谢回复=)
标签: c# asp.net timer reload code-behind