This post asks this question, but doesn’t really give an answer, so I decided to ask the question differently.
I have a page that displays a hidden value from a model:
<%=Html.Hidden("myName", model.myValue) %>
Since I pass the value in the value parameter, you think that it will output that value, but it is not.
The code for the render input fields has the following:
string attemptedValue = (string)htmlHelper.GetModelStateValue(name, typeof(string));
tagBuilder.MergeAttribute("value", attemptedValue ?? ((useViewData) ? htmlHelper.EvalString(name) : valueParameter), isExplicitValue);
Basically, if a ModelState (containing published values) contains the value of the passed “name”, it will use that value instead of the passed value for the helper method. In my case, I updated the model and my updated value was not output.
If I pass a value to a method, I expect that value to be displayed.
- ?