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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T16:45:14+00:00 2026-05-11T16:45:14+00:00

I have an issue cropping up in a form I’m trying to post. In

  • 0

I have an issue cropping up in a form I’m trying to post. In the scenario where the form doesn’t validate, I’m taking the standard route of calling ModelState.AddModelError() then returning a View result.

The thing is, the HTML.* helpers are supposed to pick up the posted value when rendering and I’m noticing that my text fields ONLY do so if I include them in the parameter list of the postback action, which shouldn’t be required seeing as some forms have way too many fields to want to list them all as parameters.

My action code is roughly:

[AcceptVerbs(HttpVerbs.Post)]
public ActionResult EditDataDefinition(long? id, string name)
{
    var dataDefinition = ...

    // do some validation stuff
    if (!ModelState.IsValid)
    {
        // manually set checkbox fields via ViewData seeing as this STILL doesn't work in MC 1.0 :P
        // ...
        return View(dataDefinition);
    }

}

Now, dataDefinition (which is a LINQ to SQL entity) has a field MinVolume, is handled in the view by this line:

Minimum: <%= Html.TextBox("MinVolume", null, new { size = 5 })%>

Yet when the view is rendered after a failed ModelState validation, the value typed into it on the original page we posted is not preserved UNLESS I include it as a parameter in the postback method. Literally, I can “solve the problem” by doing this:

[AcceptVerbs(HttpVerbs.Post)]
public ActionResult EditDataDefinition(long? id, string name, string minVolume)

For some reason that will force the field value to be preserved. This seems stupid to me because my form has way more values than just that and I shouldn’t have to add a parameter for just that field.

Any ideas?

  • 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-11T16:45:15+00:00Added an answer on May 11, 2026 at 4:45 pm

    Could it be that your code:

    <%= Html.TextBox("MinVolume", null, new { size = 5 })%>
    

    ..has the null for the default value param? Maybe if you change the null to Model.MinVolume it will persist the value. Like this:

    <%= Html.TextBox("MinVolume", Model.MinVolume, new { size = 5 })%>
    

    I’m not sure if your action returns the value MinVolume in the model tho. If it does, the above should work. Else, you may need to refactor the action slightly.

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

Sidebar

Related Questions

I have issue that is reproduced on g++. VC++ doesn't meet any problems. So
I am trying to use jquery validate plugin on my 5 questions quiz form.
Im writing sql query and i have issue which i cannot fix. I'm trying
I have a form_for a comment. Comments belongs_to Issue. I have a comments form
I have written a code that I use for cropping purpose. The scenario is
I have an odd issue cropping up with an NSOutlineView. The view is essentially
We are new to ROR, We have issue in creating Login/Logout process in ROR
Share your ideas please! I have issue to check the folder and convert a
I have an issue with an open source C++ project that I have been
I have an issue. One of my JS scripts needs Facebook SDK and Twitter

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.