2012-08-15 72 views
0

我有BackoutClaim頁面。點擊提交按鈕,我必須禁用按鈕,並從POst方法中,當響應返回時,我必須啓用按鈕。提交按鈕不禁用ASP.NET MVC頁面

在下面的代碼中,該按鈕沒有禁用。 欣賞你的迴應。

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server"> 

    <script type="text/javascript"> 
     function TrimThatNameThenSubmit() { 
      var tableName = $('#tableName').val().replace(/^\s+|\s+$/g, ""); 
      $('#tableName').val(tableName); 
      **$('#Submit').attr('disabled', 'disabled');** 
      $('form:eq(0)').submit(); 

     } 
</script> 

<% 
    var messages = ViewData["messages"]; 
%> 
<% using (Html.BeginForm()) { %> 
    <div> 
     <div class="Spacer"></div> 

     <div class="RevertCaseStateHeader" align="center"> 
      <%= Html.TextBox("tableName", "Enter tableName to Backout Claim", new { @style = "width: 400px;" })%> 
      <input type="button" value="Submit" onclick="javascript:TrimThatNameThenSubmit()"/> 
     </div> 
      <div class="RevertCaseStateSummary" align="center"> 
      <% if (messages != null) 
       { %> 
        <%= Html.Encode(messages)%> 
      <% } %> 
      </div> 
    </div> 
<% } %> 

</asp:Content> 
+0

我敢肯定,下面一行是沒用的:$('形式:當量(0)')提交(); – Pluc 2012-08-15 16:48:02

回答

2

你jQuery是選擇與ID按鈕=提交不存在,您的按鈕定義修改爲:

<input id="Submit" type="button" value="Submit" onclick="javascript:TrimThatNameThenSubmit()"/>