Wednesday, April 25, 2012

Custom Validation in ASP.NET MVC 3 using Data Annonations Model Validator

This critical instant will demonstrate implementation of custom validation rules in ASP.NET MVC3 according to offshore .net developers. MVC3 is every extensible framework that makes .net developers to adject user defined specific custom validations by the use of custom data annotations. Considering boon outsource .net development scenario the .snare developers need to develop an industry for Loan processing system.

In your hypothesis it will ask the customer to take up his details including Name, Salary etc. If the loan is to be processed then there is a rule that the Salary mouldiness be more than or equal to Rs 20000/-. Considering inferior scenario end-users need to be provided with the feedback details by which en error message would exist displayed on the screen if end-user enters below the specified footing.

In case of implementing custom validation and applying it to use Data Annotations your class must come into possession of as an heir from ‘ValidationAttribute' class. This class is the base class for all standard data annotations types.

The before anything else step would be to open VS2010 and be the occasion of a new ASP.NET MVC 3 contrive. .Net developers need to name it as ‘ASPNET_MVC3_Custom_ModelValidation'.

The next step is of adding a repaired folder in the project and named considered in the state of ‘CustomizedValidators'. Add a new class file named as "CustomValidator.cs" in this folder. This class contains custom validation class and given conditions annotations class. Dot net developers strait to write the below code:

No comments: