2011-11-06 82 views
0

我想在visual studio中创建一个按钮,刷新整个浏览器页面。目前,我有一个部署到SharePoint 2010的Web部件。我想添加一个按钮来动态刷新页面,以便我的Web部件内容发生更改。这是因为,我的Web部件有一个随机代码,每10秒更改一次信息,但要查看页面必须不断刷新的更改。我只想添加一个按钮到我的Web部件来刷新。可能吗?刷新页面按钮使用C#

+1

为什么在每个浏览器中都有一个完美的按钮时,在网页上添加按钮? –

+1

您可以使用ajax – mpen

+1

如果您想自动刷新,请尝试启用AJAX的Web部件 – Damith

回答

0

有几种方法,但都在按钮上使用JavaScript。以下是我的最爱:

<input type=button value="Refresh" onClick="history.go()"> 

“type = button”可防止按钮导致回发。 onclick="history.go()表示转到历史列表中的最后一项,即当前页面。

0

你可以试试这个.....如果你想刷新页面中单击按钮,可以设置到这个按钮,点击....

<html> 
<head> 
<script type="text/JavaScript"> 
<!-- 
function timedRefresh(timeoutPeriod) { 
    setTimeout("location.reload(true);",timeoutPeriod); 
} 
// --> 
</script> 
</head> 
<body onload="JavaScript:timedRefresh(5000);"> 
<p>This page will refresh every 5 seconds. This is because we're using the 'onload' event to call our function. We are passing in the value '5000', which equals 5 seconds.</p> 
<p>But hey, try not to annoy your users too much with unnecessary page refreshes every few seconds!</p> 
</body> 
</html> 
0

使用这一个 输入类型=“button”value =“重载页面”onClick =“window.location.reload()