2011-11-06 120 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()