Understanding ASP.NET Validation ControlsAfter you create a web form, you should make sure that mandatory fields of form elements such as login name and password are not left blank; data inserted is correct and is within specified range. Validation is method of scrutinizing that user has entered correct values in input fields. In HTML you can perform validation either by checking values at client-side or after submitting form at server-side. But these methods in HTML take lots of time to create and maintain code. Moreover, if user has disabled JavaScript then he or she may not receive message regarding error.
Therefore, in ASP.NET you can use ASP.NET Validation Controls while creating form and specify what ASP.NET Validation Controls you want to use and to which server control you want bind this. ASP.NET Validation Controls are derived from a common base class and share a common set of properties and methods. You just have to drag and drop ASP.NET Validation Control in web form and write one line of code to describe its functionality.
This reduces developer time from writing JavaScript for each type of validation. Moreover, through ASP.NET Validation Controls if any invalid data is entered browser itself detects error on client side and displays error without requesting server. This is another advantage because it reduces server load.
The five types of ASP.NET Validation Controls in ASP.NET Framework include:
• RequiredField Validation control: prompts message if any input field is left blank. This validation control can also be used to prompt message to user if he or she has left any input field with its default value.