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.
This guy has more info.
If I helped you out today, you can buy me a beer below. Cheers!
No comments:
Post a Comment
Comments are very welcome but are moderated to prevent spam.