Html.HiddenFor() isn't updated correctlyhttp://forums.asp.net/t/1807644.aspx/1?Html+HiddenFor+isn+t+updated+correctlyFri, 25 May 2012 20:38:48 -040018076444998063http://forums.asp.net/p/1807644/4998063.aspx/1?Html+HiddenFor+isn+t+updated+correctlyHtml.HiddenFor() isn't updated correctly <pre class="prettyprint">public class SectionQuestionsViewModel { public int MdsId { get; set; } public int SectionId { get; set; } public int PrevSectionId { get; set; } public int NextSectionId { get; set; } public SectionQuestionColl answers { get; set; } }</pre> <p>And the razor code looks like this:</p> <pre class="prettyprint">@using (Html.BeginForm(new { mdsId = @Model.MdsId, sectionId = @Model.SectionId})) { @Html.HiddenFor(x =&gt; x.PrevSectionId) @Html.HiddenFor(x =&gt; x.NextSectionId) @* ... snip ... *@ }</pre> <p>The first time in, the Prev/Next values are {0,3}, when the user clicks on the next button, they get section 3.&nbsp; The code, all the way to the @Model in the view, shows that the Prev/Next are {2,4}, but when I look at the HTML, the values are still {0,3}.&nbsp;</p> <p>What is going on?</p> <p>Sam</p> 2012-05-25T20:05:26-04:004998089http://forums.asp.net/p/1807644/4998089.aspx/1?Re+Html+HiddenFor+isn+t+updated+correctlyRe: Html.HiddenFor() isn't updated correctly <p>The form submit takes precedence over the modified in the action.</p> <p>Please use ModelState.RemoveKey(&quot;<span class="pln">PrevSectionId&quot;)</span></p> <p></p> 2012-05-25T20:38:48-04:00