我對此有點新,而我的英語也很差。無論如何:如何從後面的代碼刷新一個asp頁面? C#
我想設置一個計時器,刷新我的網頁,如果有任何新的記錄在我的報告。顯然我的計時器工作正常,因爲當我調試它進入功能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>
編輯:
- 我使用.NET框架3.5
- 我試過這個post但它不起作用。
- 感謝您的回答。
有你在你的應用程序中使用SignalR考慮? – rajeemcariazo 2015-02-06 15:51:30
@rajeemcariazo我不熟悉SignalR,生病看看謝謝 – 2015-02-06 16:02:13
@Izzy我已經試過這個帖子,但沒有任何作品,謝謝 – 2015-02-06 16:02:39