Is there any way to ignore some properties (on a POCO) when validating a form in ASP.NET MVC3?

前端 未结 9 589
春和景丽
春和景丽 2021-02-05 05:59

i\'ve got a sign up wizard for new user registration. When I try to goto the 2nd page, I get validation errors because my User object hasn\'t been fully populated,

9条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-05 07:03

    You can use the Bind Attribute for this: http://ittecture.wordpress.com/2009/05/01/tip-of-the-day-199-asp-net-mvc-defining-model-binding-explicitly/

    A better option would be to use ViewModels.

    http://weblogs.asp.net/shijuvarghese/archive/2010/02/01/view-model-pattern-and-automapper-in-asp-net-mvc-applications.aspx

提交回复
热议问题