Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7021885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:30:30+00:00 2026-05-27T23:30:30+00:00

In this question disabling the submit button to prevent multiple postbacks was a viable

  • 0

In this question disabling the submit button to prevent multiple postbacks was a viable solution to stop (non-malicious) users from posting back multiple times.

This option doesn’t work well if you have a view with multiple submit buttons. Take the following example.

//View:

@using (Html.BeginForm("Catalog", "Images", FormMethod.Post, new { onsubmit = "Utility.disable_buttons(this.id);", id = "catalog_form" }))
{
<p>
    <input type="submit" name="btnSubmit" value="Clear" /> |
    <input type="submit" name="btnSubmit" value="Catalog" /> |
    <input type="submit" name="btnSubmit" value="Update" /> |
    @Html.ActionLink("Back to List", "Index")
</p>
}

//Controller:

[HttpPost]
    public ActionResult Catalog(string btnSubmit)
    {
        switch (btnSubmit)
        {
            case "Catalog":
                //More differenter code
                break;
            case "Clear":
                //Different code
                break;
            case "Nothing":
                //Code
                break;
        }
        return View();
    }

In the view, there are three different submit actions. If the buttons are disabled, then their values won’t be passed and the controller will not know which button triggered the submit. (The controller always gets null.) Unfortunately, the submitdisabledcontrols attribute does not seem to solve this problem in MVC. Does anybody know how to pass disabled control’s values to the server?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T23:30:31+00:00Added an answer on May 27, 2026 at 11:30 pm

    Some background info:

    • Disabled form data such as disabled submit buttons will not be posted back to the server: http://www.w3.org/TR/html4/interact/forms.html#h-17.12.1
    • If a form contains multiple submit buttons only the clicked ones value will be posted back to the server: http://www.w3.org/TR/html4/interact/forms.html#successful-controls

    If you want to disable all buttons so they are no longer clickable but still want to know what the user clicked the only solution I can think of is a hidden field along with this code:

    $(function() {
        $('input[type=submit]').click(function() {
            var form = $(this).closest('form');
            form.find('#hiddenField').val($(this).val());
            form.find('input[type=submit]').prop('disabled', true);
        });
    });
    

    If you just want to make sure the user cannot click the other buttons after clicking one you can do this:

    $(function() {
        $('input[type=submit]').click(function(event) {
            $(this).closest('form').find('input[type=submit]').not(this).prop('disabled', true);
        });
    });
    

    Unfortunately there is no solution (I know of) to bind a handler to the form´s submit and determine which input was clicked. This is not a problem related to your question but makes the above code slightly more complicated.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question is about removing sequences from an array, not duplicates in the strict
This question has been asked many times, but I tried every solution and none
I asked this question previously: Disabling and Re-Enabling Dynamic Form Elements with JQuery but
I'm trying to prevent a user from disabling style.(I HAVE A GOOD REASON TO
This question is kind of an add-on to this question In C#, a switch
This question and answer shows how to send a file as a byte array
This question comes on the heels of the question asked here . The email
This question would probably apply equally as well to other languages with C-like multi-line
This question is a follow up to my previous question about getting the HTML
(This question is over 6 years old and probably no longer has any relevance.)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.