Web Connection
Disabling Submit Button not executing Click Event
Gravatar is a globally recognized avatar based on your email address. Disabling Submit Button not executing Click Event
  Jim Day
  All
  Dec 30, 2024 @ 06:41pm
<ww:wwWebButton ID="btnSubmit" runat="server" 
Width="100" Click="btnSubmit_Click" Text="Submit" />


<script src="/lib/jquery/dist/jquery.min.js"></script>
<script>
    $(document).ready(function () {

        $("#frmeMailReport").submit(function (e) {

            //stop submitting the form to see the disabled button effect
            //e.PreventDefault();

            //disable the submit button
            $("#btnSubmit").attr("disabled",true);
       
            return true;

        });
    });
</script>
<

The Submit button is disabled but the Click="btnSubmit_Click" is not executed. Seem to be missing something.

Gravatar is a globally recognized avatar based on your email address. re: Disabling Submit Button not executing Click Event
  Rick Strahl
  Jim Day
  Dec 30, 2024 @ 09:41pm

If you disable the button, the button's name is not included in the POST data to the server and if I recall right the server won't see the event. Turn on logging on the server and see what's in the POST data and compare between disabling and not disabling and see what difference that makes and whether it even hits the server with the button disabled.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: Disabling Submit Button not executing Click Event
  Jim Day
  Jim Day
  Dec 31, 2024 @ 12:47pm

Panel_btnSubmit=Submit

Above is missing when the Submit button is disabled.

Gravatar is a globally recognized avatar based on your email address. re: Disabling Submit Button not executing Click Event
  Jim Day
  Jim Day
  Dec 31, 2024 @ 01:04pm
                <% pcPageTitle = "Reports" %>
                    <% Layout="~/views/_layoutpage.wcs" %>

                   <td class="blockheader" align="center" valign="top" style="height: 40px; ">
                    <button type="submit" id="btnSubmit" name="btnSubmit" style="width: 120px"
                    <i class="fa fa-check"></i> Submit
                    </button>

<script src="~/lib/jquery/dist/jquery.min.js"></script>
<script>
    $(document).ready(function () {

        $("#frmReports").submit(function (e) {

            //stop submitting the form to see the disabled button effect
            //e.preventDefault();

            //disable the submit button
            $("#btnSubmit").attr("disabled", true);

            //disable a normal button
            $("#btnTest").attr("disabled", true);

            return true;

        });
    });
</script>

The above code works but the submit button is not passed but the code I want to run is in the post back which is executed without needing to execute a "Click Event"

Gravatar is a globally recognized avatar based on your email address. re: Disabling Submit Button not executing Click Event
  Jim Day
  Jim Day
  Dec 31, 2024 @ 01:21pm
<script>
$(document).ready(function(){
 $("#frmReports").submit(function (e) {
    $("#Panel_btnSubmit").hide("fast");
  });
});
</script>

This does the trick. Thanks for your help.

© 1996-2025