开发者

ASP.NET MVC 3 keep posted form data in form when there are binding errors

When a user posts a form to register, if ModelState is not va开发者_开发百科lid, I would like to have the input form values placed back into the appropriate form fields so they do not have to fill out the entire form again. I could pass back the object to the view and then set the value field on each form input. Is this the only way to do it.

Thanks


The HTML helpers by default exhibit this behavior. How are you coding this? Html.TextBoxFor does this for example. The helpers use the posted values when you are in a post action and render a view without redirecting.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜