ASP.Net MVC partial views keeping their model state?

前端 未结 5 1979
灰色年华
灰色年华 2021-02-08 19:34

This is probably again a newbie question.

When I create an ASP.NET MVC2 application, an Account Controller with an Action LogIn is created like this:

[H         


        
5条回答
  •  青春惊慌失措
    2021-02-08 20:08

    I had the same issue when used Ajax.BeginForm, where i needed to return a partial view, but all the modelstate errors were gone. what does the trick is to isolate the Ajax.BeginForm part to a separate View, and RenderPartial this view within the UpdateTargetId div in another, containing view.

    This way you can return the viewmodel with the model errors when you have them, or else just show some success message of your choice (if any). here is a great, detailed explanation: http://xhalent.wordpress.com/2011/02/05/using-unobtrusive-ajax-forms-in-asp-net-mvc3/

提交回复
热议问题