2011-09-26 82 views
3

如何使用Javascript 禁用/啓用asp.net定時器控制我的代碼是:(但不工作)如何禁用/啓用使用JavaScript的asp.net計時器控件?

function timeroff() 
{ 
     var b = document.getElementById('Timer1'); 
     if (b) { 
      b.disabled = true; 
     } 
    } 
    function timeron() { 
     var b = document.getElementById('Timer1'); 
     if (b) { 
      b.disabled = false; 
     } 
    } 
+0

以下鏈接重定向到其他地方現在:))) –

回答

0

下面的作品,只要計時器未在主頁上,因爲你會得到一個錯誤,指出「控件集合無法修改,因爲控件包含代碼塊(即<%...%>)。」「當您將此javascript放在主頁頁眉中時。

function enableTimer() { 
    var timer = Sys.Application.findComponent(‘<%= Timer1.ClientID %>’); 
     timer.set_enabled(true); 
    } 
    function disableTimer() { 
     var timer = Sys.Application.findComponent(‘<%= Timer1.ClientID %>’); 
     timer.set_enabled(false); 
    } 

看到:http://weblogs.asp.net/andrewfrederick/controlling-the-asp-net-timer-control-with-javascript瞭解更多詳情

+0

我試了好幾種技術,試圖從母版頁做同樣的事情,但我不知道你將如何從母版頁做到這一點,因爲我沒有嘗試過的方法工作... –

相關問題