I'm just getting started with ASP.NET MVC 2, and playing around with Validation.
Let's say I have 2 properties:
- Password1
- Password2
And I want to require that they are both filled in, and require that both are the same before the model is valid.
I have a simple class called "NewUser".
How would I implement that? I've read about ValidationAttribute, and understand that. But I don't see how I would use that to implement a validation that compares two or more properties against eathother.
Thanks in advance!
Problem with below solution:
When this is applied to an application, and the ModelBinder runs the validation of the Model, then there is a problem:
If a Property-level ValidationAttribute contains an error, then the Class-level ValidationAttribute's are NOT validated. I have not found a solution to this problem as of yet.
If you have a solution to this problem please share your experience. Thanks alot!