开发者

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();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜