Where does asp.net mvc text box input value is taken?
I have a url like this:
http://localhost/products/AddFeature?code=SMW
in the controller action, I create a model and set the
model.Code = "123112".
The View has this
@Html.EditorFor(mo开发者_开发知识库del => model.Code)
the final rendered html always shows "SMW" as the value.
Is this a bug where the query string value overrides the assigned value ? Does anyone got same results or I need some coffee ?
Clear the model state before returning your view. Be sure that you haven't missed some model error before you do that. The helpers use the ModelState, then the models for their values.
ModelState.Clear();
精彩评论