2013-01-21 136 views
1

我禁用了使用JavaScript代碼的按鈕,但我的服務器端事件沒有解僱..任何想法?ASP.Net按鈕禁用

Javascript 
------------------------ 

     function DisableButton() { 
      if (typeof (Page_ClientValidate) == 'function') { 
       Page_ClientValidate(); 
      } 
      if (Page_IsValid) { 
       document.getElementById('<%=BtnToprimaryValidation.ClientID%>').disabled = true; 
       document.getElementById('<%=BtnToprimaryValidation.ClientID%>').value = 'Please wait ...'; 
      } 
     } 

ASP.Net 
------------------------- 
<asp:Button ID="BtnToprimaryValidation" runat="server" 
         meta:resourcekey="BtnToprimaryValidationResource1" 
         CssClass="submitButton"> 

Server Side c# 
--------------------------- 

     protected void Page_Load(object sender, EventArgs e) 
     { 
      BtnToprimaryValidation.Click += BtnToprimaryValidationClick; 
     } 
     protected void BtnToprimaryValidationClick(object sender, EventArgs e) 
     { 
     } 

由於事先 拉胡爾·[R

回答

0

事件不火上禁用的項目

,而不是禁用的,你必須改變你的DisableButton方法return false,就像這樣:

function DisableButton() { 
     if (typeof (Page_ClientValidate) == 'function') { 
      Page_ClientValidate(); 
     } 
     if (Page_IsValid) { 
      document.getElementById('<%=BtnToprimaryValidation.ClientID%>').value = 'Please wait ...'; 
     } 
     else { 
      return false; 
     } 
} 
0

正如前面回答012所述,事件不會在禁用的按鈕上觸發

使用短超時先觸發事件,然後禁用按鈕:

setTimeout(function(){ 
document.getElementById('<%=BtnToprimaryValidation.ClientID%>').disabled = true; 
}, 100); 

就像我建議在this question