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 8799539
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:21:03+00:00 2026-06-14T00:21:03+00:00

I’m using MVC 4 on the .Net platform and have the following html in

  • 0

I’m using MVC 4 on the .Net platform and have the following html in my view. As you can see the names are the same to distinguish which button is pressed when going into the Controller to take the proper action.

<tr>
    <td>
        <input type="submit" name="submitbutton" id="btnRefresh" value='Refresh' />
    </td>
        @if (Model.ShowGeneratePDFBtn == true)
        {
            <td>
                <input type="submit" name="submitbutton" id="btnGeneratePDF" value='Generate PDF' />
            </td>
        }
</tr>

However, when the second (“Generate PDF”) button is pressed, I need to disable it so the user won’t be able to press it again while a process is taking place. If I disable it, it no longer appears in the html as a control (which is understandable).

Here is the js:

$('#btnGeneratePDF').click(function () {
    DisableGeneratePDF();
});

function DisableGeneratePDF() {
    $('#btnGeneratePDF').attr("disabled", true);
}

In the Controller, the value of the button when pressed is null instead of “Generate PDF”, so the proper action doesn’t get executed.

Here is the first line in the Controller:

[HttpPost]
public ActionResult ProcessForm(string submitbutton, ViewModelTemplate_Guarantors model, FormCollection collection)

Here is the first line in the View. I also tried it with FormMethod.Post, but since I’m not going to another page the AjaxOption would be more efficient.

@using (Html.BeginForm("ProcessForm", "Home", new AjaxOptions { HttpMethod = "POST" }))

How can I successfully pass the “Generate PDF” value to the Controller when I disable the button?

  • 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-06-14T00:21:06+00:00Added an answer on June 14, 2026 at 12:21 am

    Create a hidden form value and put this in your view model. Then set that value in you click event handler.

    To your model, add the following

    public class Guarantors
    {
        public bool ShouldGeneratePdf { get; set; }
    }
    

    To your view, add

    @Html.HiddenFor(x => x.ShouldGeneratePdf)
    

    To your JavaScript

    $('#btnGeneratePDF').click(function () {
        DisableGeneratePDF();
        $('#ShouldGeneratePdf').val('True');
    });
    
    function DisableGeneratePDF() {        
        $('#btnGeneratePDF').attr("disabled", true);
    }
    

    That ought to do it.

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

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
I have thousands of HTML files to process using Groovy/Java and I need to
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have an autohotkey script which looks up a word in a bilingual dictionary
I have an array which has BIG numbers and small numbers in it. I

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.