view more software Tips and Tricks
Updated: 09/18/2013 11:09 AM
Author: Shiju Mathews
I am creating a custom attribute to compare StartDate and EndDate on a model and make sure that EndDate is not earlier than StartDate.
Add a class to the project in Validation folder named GraterThanDateAttribute, that is inherited from ValidationAttribute.
create a model(class) named TimeCard in the model folder(or any sub filder, I created a folder called "TimeSheet" under Model folder).
Add a reference to validation name space(SoftwareTalk.Validation) to the Model class
Add the Properties to the model class.
Now we are ready to use the model "TimeCard" any where in the MVC application.
Now you can extend the functionality by adding client side custom ValidationAttribute How to create a client side custom ValidationAttribute in MVC 3