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

  • Home
  • SEARCH
  • 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 7659007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:16:32+00:00 2026-05-31T13:16:32+00:00

I have a new MVC 4 Application with a fairly basic View/Controller. The associated

  • 0

I have a new MVC 4 Application with a fairly basic View/Controller. The associated Model contains a couple properties that I’ve mapped to Hidden form fields. When the Page renders the first time (e.g. via the HttpGet Action) it all looks fine. But when the form is Post’ed by selecting the Submit button the resulting Model presented to the Action no longer has the Hidden field values set. Here is a walkthrough of the particulars.

Here is a sample of the Model:

public class Application
{
    public bool ShowSideBars { get; set; }
}

Here is the initial Controller *Action* (which seems to work fine):

[HttpGet]
public ActionResult Application()
{
    var model = Request.ParseFromQueryString<Application>();
    model.ShowSideBars = true;

    return View(model);
}

This maps to the View as follows:

<fieldset>
    @Html.HiddenFor(m => m.ShowSideBars)
...
</fieldset>

This results in the following mark-up to be rendered inside the fieldset:

<input data-val="true" data-val-required="The ShowSideBars field is required." id="ShowSideBars" name="ShowSideBars" type="hidden" value="True" />

Note: I sure wish I knew why MVC has decided to add the ‘… field is required’ content when I didn’t flag it as required, but that’s for another question

Here is the Action that is called when the form is submitted. At this point the aforementioned property will no longer be set to ‘true‘.

[HttpPost]
public ActionResult Application(Application application)
{
    // Other work done here

    return View(application);
}

At present, there are no custom Model Binders. Also, I’ve tested some other data types and I’m seeing the same thing.

Can someone explain why hidden form values are not being returned? Am I just doing this all wrong?

  • 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-31T13:16:33+00:00Added an answer on May 31, 2026 at 1:16 pm

    I cannot reproduce the issue (ASP.NET MVC 4 Beta running on VS 2010 .NET 4.0).

    Model:

    public class Application
    {
        public bool ShowSideBars { get; set; }
    }
    

    Controller:

    public class HomeController : Controller
    {
        public ActionResult Application()
        {
            var model = new Application();
            model.ShowSideBars = true;
            return View(model);
        }
    
        [HttpPost]
        public ActionResult Application(Application application)
        {
            return Content(application.ShowSideBars.ToString());
        }
    }
    

    View:

    @model Application
    
    @using (Html.BeginForm())
    {
        @Html.HiddenFor(m => m.ShowSideBars)
        <button type="submit">OK</button>
    }
    

    When I submit the form, the model binder correctly assigns the ShowSideBars property in the POST action to true.

    Note: I sure wish I knew why MVC has decided to add the ‘… field is
    required’ content when I didn’t flag it as required, but that’s for
    another question

    That’s because non-nullable types such as booleans are always required. You could stop ASP.NET MVC helpers from emitting HTML5 data-* client side validation attributes for them by putting the following line in Application_Start:

    DataAnnotationsModelValidatorProvider.AddImplicitRequiredAttributeForValueTypes = false;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a new ActionFilter for an ASP.NET MVC application that I'm creating.
I have a new solution that is an ASP.NET MVC 2.0 application. I have
I have an application (ASP.NET MVC) that uses a Next New method to get
I am new to MVC and have a grasp of the basic model, but
I have a new ASP.Net MVC application that I am about to start and
I have been working on a new MVC application that utilizies EF4, POCO Domain
In my MVC application I have the following mapping: routes.MapRoute(testRoute, services/service.js, new {controller =
I have started a new mvc project and clicked on project\properties\web - use local
I am just new in MVC 3. I have a html view which contain
I have a fairly simple data audit web application written with ASP MVC which

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.