2010-10-07 39 views
1

我在網格視圖內的標籤中顯示時間。我需要每秒刷新標籤。如何通過Java腳本來做到這一點。就像Ajax計時器一樣。如何刷新使用Java腳本的Grid視圖內部的Label?

編輯:

OnLoad="setTimeout(window.location.reload();. 1000);"什麼是錯,此代碼或<asp:Label ID="Label2" Width="100px" runat="server" OnLoad="setTimeout(window.location.reload();. 1000);" Font-Size="12px" ForeColor="Black" Text='<%# Bind("time") %>'></asp:Label>

回答

1
setInterval(function(){ 
    var now = new Date(); 
    $('#yourSpanId').text(now.toUTCString()); // or whatever formatting you need 
}, 1000); 
+0

沒有我使用C#代碼已經綁定的時間behind..just我需要刷新它,這樣它看起來像數字時鐘。 – TinTin 2010-10-07 06:10:48

+0

你需要刷新你的網格嗎?你在使用UpdatePanel嗎?一些代碼示例將會很有用... - 或者只是Google for'Ajax timer' – 2010-10-07 06:16:36

+0

OnLoad =「setTimeout(window.location.reload();. 1000);」這個代碼有什麼問題或 TinTin 2010-10-07 07:16:03