Class/Model Level Validation (as opposed to Property Level)? (ASP.NET MVC 2.0)

后端 未结 6 2165
忘掉有多难
忘掉有多难 2020-12-14 10:31

Basically, what the title says. I have several properties that combine together to really make one logical answer, and i would like to run a server-side validation code (tha

6条回答
  •  天涯浪人
    2020-12-14 11:20

    I know that this has already been answered but it appears that MVC3 has added another way to accomplish this if you want to continue using DataAnotations Attributes.

    Your class can implement the IValidatableObject interface which provides a Validate method. Just another way to skin a cat.

提交回复
热议问题