0

我有 BackoutClaim 页面。单击提交按钮时,我必须禁用该按钮,并且从 POst 方法中,当响应返回时,我必须启用按钮返回。

在下面的代码中,按钮未禁用。感谢您的回复。

    <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>
4

1 回答 1

2

您的 jQuery 正在选择不存在 id=Submit 的按钮,请将您的按钮定义更改为:

<input id="Submit" type="button" value="Submit" onclick="javascript:TrimThatNameThenSubmit()"/>
于 2012-08-15T16:04:31.710 回答