在ASP.NET MVC自动刷新 [英] Auto refresh in ASP.NET MVC
本文介绍了在ASP.NET MVC自动刷新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在网络表单我做
<script type="text/JavaScript">
function timedRefresh(timeoutPeriod) {
setTimeout("location.reload(true);", timeoutPeriod);
}
</script>
<body onload="JavaScript:timedRefresh(5000);">
或codebehind的Page_Load
or codebehind Page_Load
Response.AddHeader("Refresh", "5");
问题如何使屏幕刷新,每5秒ASP.NET MVC3
Question How to make the screen refresh every 5 seconds in ASP.NET MVC3
推荐答案
您可以做同样的MVC中:
You could do the same in MVC:
<script type="text/javascript">
function timedRefresh(timeoutPeriod) {
setTimeout(function() {
location.reload(true);
}, timeoutPeriod);
}
</script>
<body onload="JavaScript:timedRefresh(5000);">
...
</body>
或使用meta标签:
<head>
<title></title>
<meta http-equiv="refresh" content="5" />
</head>
<body>
...
</body>
或在你的控制器动作:
public ActionResult Index()
{
Response.AddHeader("Refresh", "5");
return View();
}
这篇关于在ASP.NET MVC自动刷新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文