Instructor-led online courses in ASP.NET Core, ASP.NET MVC, and ASP.NET Design Patterns. Read more...
Instructor-led online courses in ASP.NET Core, ASP.NET MVC, and ASP.NET Design Patterns. Conducted by Bipin Joshi on weekends. More details are available here.

<%@ Page %>

ASP.NET Validation Controls Samples For Beginners


Most of the times while submitting forms we need to validate the user input for certain criteria. In ASP there was no other way but to write our own server or client side validation routines. ASP.NET frees the programmer from performing common validation tasks through the use of special web controls called validation controls. These 10 code samples will show you how to use all of the available validation controls.

There are 6 types of validation controls available :

  • RequiredFieldValidator
  • CompareValidator
  • RangeValidator
  • RegularExpressionValidator
  • CustomValidator
  • ValidationSummary

Sample Listing

Following samples are included with the download:
  • RequiredFieldValidator on textboxes
  • RequiredFieldValidator on listboxes
  • Compare values of two textboxes
  • Compare value of textboxe with listbox item
  • Check number range and date range
  • Check format of URL and Email address
  • Custom validation at client side
  • Custom validation at server side
  • Using ValidationSummary control
  • Validating controls at server side

To run the samples you will need...

  • Windows 2000 with .NET Framework installed
  • IIS 5+
  • Visual Studio.NET

How to run/view the code?

  • Create ASP.NET Web application in VS.NET named ValidationControls
  • Download and un-zip the supplied files in the web application root
  • Include the files in the project by Add -> Existing Item menu command
  • Set the page you want to run as start page and run the application

Bipin Joshi is a software consultant, trainer, author and spiritual yoga mentor having 23+ years of experience in software development. He teaches online training courses in ASP.NET Core, ASP.NET MVC, and Design Patterns to individuals and small groups. He is a published author and has authored or co-authored books for Apress and Wrox press. Having embraced the Yoga way of life he also teaches Ajapa Yoga to interested individuals. To know more about him click here.

Get connected : Twitter  Facebook  Google+  LinkedIn

Posted On : 12 April 2002

Tags : ASP.NET Web Forms Server Controls JavaScript

Subscribe to our newsletter

Get monthly email updates about new articles, tutorials, code samples, and how-tos getting added to our knowledge base.