13 Apr 2012

I have a Controller that passes a Model to a View.
The Controller receives the Model in a postback and modifies one of the Model properties before passing it to the View.
The View uses the Html.HiddenFor HtmlHelper to include the modified Model property in a Form.

BUT!!!! The HTML shows that the View is not rendering the modified Model property value! Instead it's rendering whatever the property value was when it was POSTed.

In short: HtmlHelpers use the posted form collection values in preference to the explicitly set model value. To me that's counter-intuitive.

Anyway, the best workaround is to use hand-made <input /> tags instead of using the HtmlHelpers. Feels hacky but works.