title: html.hidden for losing value when name attribute is changed
body: <p>I have an <code>@html.editorfor</code> and an <code>@html.hiddenfor</code> element in <code>my.cshtml</code> view, and on a button click event I'm changing both of the elements' name attributes so that I can post them in a separate list.</p>
  
  <p>The value of the <code>editorfor</code> element is supposed to be a string in the model, but the value of the <code>hiddenfor</code> element is supposed to be an int.</p>
  
  <p>The problem is that the new list is returning with the right editor value but the hidden value is always returning "0" even though it should be something else. Is there a different way of posting an int value back in a list?</p>
  
  <p>by the way, when I'm posting the values of the elements back without changing their name attributes, everything is posting back correctly.</p>
  
  <p>heres the script that I'm using to change the name attributes:</p>
  
  <pre><code>//inside for loop where i is the iteration index
  @Html.HiddenFor(m =&gt; m[i].EmployeeTimeSeriesDataID, new { htmlAttributes = new { @id = "tsdata_hidden_" + i } })
  
  &lt;script&gt;
   $('somebutton').click(function() {
    var hiddenTsID = "#tsdata_hidden_" + aNumber; //number to match the i from the hidden for
    var nameOfHiddenToDeleteWithIndex = "deleteList[" + deleteIndex + "].EmployeeTimeSeriesDataID";
    //deleteindex starts at 0 and is incremented at the end of every button click, so the new list
    //can be correctly created starting with index[0]
  
    $(hiddenTsID).attr('name', nameOfHiddenToDeleteWithIndex);
   });
  &lt;/script&gt;
  </code></pre>
  
  <p>controller action:</p>
  
  <pre><code>public ActionResult TimeSeriesData(/*among other params*/EmployeeTimeSeriesData[] deleteList) {
   //working update functionality
   //working add functionality
   foreach (EmployeeTimeSeriesData tsData in deleteList)
    {
     EmployeeTimeSeriesData y = db.EmployeeTimeSeriesData.Find(tsData.EmployeeTimeSeriesDataID); 
     db.EmployeeTimeSeriesData.Remove(y);
    }
    db.SaveChanges();
  
  }
  </code></pre>