hi,
I have a ViewModel class and I would like to change one of its propetry via ajax calling.
In the controller I setted the property to the new value but the data wasn't refreshed on the UI. I debugged in the MVC framework and I found the following part of code in the input extension class:
default:
string attemptedValue = (string)htmlHelper.GetModelStateValue(name, typeof(string));
tagBuilder.MergeAttribute("value", attemptedValue ?? ((useViewData) ? htmlHelper.EvalString(name) : valueParameter), isExplicitValue);
break;
So the original value is exist in the modelstate dictionary the tagBuilder uses the attempedValue and not the valueParameter which is the new value that I setted via ajax calling.
If I clear the ModelState or remove the dictionary entry which belongs the property then the I can see the new value on the UI.
But I dont understand exactly why happend this. Is this a normal behavior of ModelState?
What is the goal of this behavior?