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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T21:40:34+00:00 2026-06-03T21:40:34+00:00

I have a form with the autocomplete attribute set to off . Inside this

  • 0

I have a form with the autocomplete attribute set to off.

Inside this form, there is a hidden input element (generated using ASP.NET MVC’s Html.HiddenFor() method, but, that should be irrelevant):

<input type="hidden" value="0" name="Status" id="Status" data-val-required="The Status field is required." data-val-number="The field Status must be a number." data-val="true">

When the form is submitted, this value is incremented by one and the model is returned to the view. If I write the status value to the page, I can see that the value was correctly incremented.

However, this hidden input field is always cached. It’s never getting the correct value. I tried setting the autocomplete attribute directly on the input element, but without success.

How can I get this hidden field to get the correct value? I’d prefer not to use any Javascript.

Edit: Supplying more code…

Controller

//This code is being executed, and the status is being incremented.
shippingOrder.Status = (shippingOrder.Status != (int)OrderStatus.Closed) ? shippingOrder.Status + 1 : shippingOrder.Status;

View

@using (Html.BeginForm("Number", "Order", FormMethod.Post, new { id = "orderSummary", autocomplete = "off" })) {
    ...
    @Html.HiddenFor(m => m.Status)
}
  • 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-03T21:40:35+00:00Added an answer on June 3, 2026 at 9:40 pm

    According to this post here html helpers such as HiddenFor will always first use the posted value and after that the value in the model.

    As you said, when writing the value to the page you can see it incremented, yet the helper is using the previously posted value, which is the intended behaviour.

    The link does suggest the use of ModelState.Remove("Status") or ModelState.Clear() before assigning the new value.

    It also suggest that another option could be not using a HiddenFor helper but instead to build the hidden field yourself. Similar to this:

    <input type="hidden" name="Status" value="@Model.Status" />

    Either way it looks like your problem is based on similar circumstances.

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

Sidebar

Related Questions

I have form in my page, I am using ajax.beginform(). Inside this form I
I have form like this: <div class=satu> <input type='text' size='1' maxlength='1' name='score[1][]' id='score[1][]'> </div>
autocomplete=off is not what I am after. Basically, on my registration form there are
<form id=search action=/search method=get autocomplete=off> <div> <input type=button name=test_button value=test /> </div> </form> <script>
I have a site with a form with autocomplete using jquery. It works fine,
I have a HTML form that mimics invoice input form. This is the way
I have a main form and non-modal autocomplete form. How can I prevent the
I have form with multiple input type=radio with text next to them. I want
i have form with user data to input and javascript ajax to send information
I have form like this : <div id='add_field' class='locbutton'><a href='#' title='Add'>Add</a></div> <div id='remove_field' class='locbutton2'><a

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.