title: MVC 4 @HTML.HiddenFor are not updating on a postback
body: <p>Having issues with the view state on a series of page views -- On the initial view of a page in Razor I am using <code>Html.HiddenFor</code> as follows: </p>
  
  <pre><code>    @Html.HiddenFor(x =&gt; Model.err)
      @Html.HiddenFor(x =&gt; Model.errField)
      @Html.HiddenFor(x =&gt; Model.errMessage)
      @Html.HiddenFor(x =&gt; Model.IsMove)
  </code></pre>
  
  <p>which seems to work fine. My hidden input tags contain the correct values.  However when I submit the form <code>[HTTPPost]</code> and update the model in my controller action with..</p>
  
  <pre><code>       model.err = transHelper.err;
         model.errField = transHelper.errField;
         model.errMessage = transHelper.errMessage;
         return View(model);
  </code></pre>
  
  <p>The hidden fields do not seem to update, they contain the original values from the initial view.  However When I use these fields in another context within the same razor view like this...</p>
  
  <pre><code>     @*      
          this seems to not update correctly...
  
      @Html.HiddenFor(x =&gt; Model.err)
      @Html.HiddenFor(x =&gt; Model.errField)
      @Html.HiddenFor(x =&gt; Model.errMessage)
      @Html.HiddenFor(x =&gt; Model.IsMove)
  
          *@
          &lt;input type="hidden" id="err" value="@Model.err" /&gt;
          &lt;input type="hidden" id="errField" value="@Model.errField" /&gt;
          &lt;input type="hidden" id="errMessage" value="@Model.errMessage" /&gt;
          &lt;input type="hidden" id="IsMove" value="@Model.IsMove" /&gt;
  
      &lt;/div&gt;
  </code></pre>
  
  <p>Then the input fields update correctly.  I even created a View Helper to help debug, and in all cases, the Model seems to have correct data in  <code>HtmlHelper&lt;TModel&gt;</code> -- I even returned the Model as <code>return Json(model);</code> and the data was fine. </p>
  
  <p>At this point I am running with the work around, but does anybody know why <code>@Html.HiddenFor</code> is dirty.</p>
  
  <p>Update:  here is my controller actions</p>
  
  <pre><code>  [HttpPost]
     public ActionResult Index(HomePageModel model)
     {
  
  
         // process transaction
         Transactionr transr = new Transactionr();
         transr.Process(model);
  
         model.err = transr.err;
         model.errField = transr.errField;
         model.errMessage = transr.errMessage;
  
         return View(model);
     }
  </code></pre>
  
  <p>Here is my view:</p>
  
  <pre><code>        @model App.Models.HomePageModel
      @{
          ViewBag.Title = "Product Categorizer";
      }
      &lt;form id="formData" method="post" action="/Home/Index"&gt;
          @Html.AntiForgeryToken()
          &lt;fieldset&gt;
              &lt;div&gt;
  
              @Html.HiddenFor(model =&gt; model.err)
              @Html.HiddenFor(model =&gt; model.errField)
              @Html.HiddenFor(model =&gt; model.errMessage)
              @Html.HiddenFor(model =&gt; model.IsMove)
  
              &lt;input type="hidden" id="myerr" value="@Model.err" /&gt;
              &lt;input type="hidden" id="myerrField" value="@Model.errField" /&gt;
  
              &lt;/div&gt;
  
             &lt;div class="section group"&gt;
                  &lt;div class="col span_2_of_2"&gt;
                       &lt;div class="message" id ="message"&gt;
                           @if (Model.err &lt; 0)
                           {
                               &lt;span style="color: purple;"&gt;@Model.errMessage (@Model.err) - (@Model.errField)&lt;/span&gt;
                           }
                           else if (Model.err &gt; 0)
                           {
                               &lt;span style="color:red;"&gt;@Model.errMessage (@Model.err) (@Model.errField)&lt;/span&gt;
                           } else {
                              &lt;span&gt;@Model.errMessage (@Model.err) (@Model.errField)&lt;/span&gt;
                           }
                           &lt;/div&gt;
                       &lt;/div&gt;
              &lt;/div&gt;
  
              &lt;div class="section group" id="workspace"&gt;
                    @Html.Partial("_WorkspacePartial", Model)
              &lt;/div&gt;
                &lt;div class="section group" id="details"&gt;
                    @Html.Partial("_DetailPartial", Model)
                &lt;/div&gt;
  
  
          &lt;/fieldset&gt;
          &lt;/form&gt;
  </code></pre>
  
  <p>Here is my model:</p>
  
  <pre><code> public class HomePageModel
   {
      public int FromStore { get; set; }
  
      //  the "To" part of the copy/move transaction
      public int ToStore { get; set; }
  
      // a list of the copy/move transaction
      public List&lt;int&gt; Details { get; set; }
  
  
      // true is move false is copy
      public bool IsMove { get; set; }
  
      // current message
      public int err { get; set; }
      public int errField { get; set; }
      public string errMessage { get; set; }
  </code></pre>