Geeks With Blogs

News Awarded Microsoft MVP C#.NET - 2007, 2008 and 2009

I am born in Bangladesh and currently live in Melbourne, Australia. I am a Microsoft Certified Application Developer MCAD Chartered Member (C# .Net)and born in Bangladesh.
I am founder and Chief Executive Officer of
Simplexhub, a highly experienced software development company based in Melbourne Australia and Dhaka, Bangladesh. Co-founder and core developer of Pageflakes
Simplexhub, is on its mission to build a smart virtual community in Bangladesh and recently launched beta an ASP.NET MVC application written in C#.NET.

Some of My Articles
Flexible and Plugin based .Net Application..
Mass Emailing Functionality with C#, .NET 2.0, and Microsoft® SQL Server 2005 Service Broker'
Write your own Code Generator or Template Engine in .NET
Shahed Khan blog

Validating user input is a very common task that we perform during web page development, and in the ASP.NET world we have a handful amount of choices to perform validation.

ASP.NET Validation Controls

ASP.NET ships with a handful amount ASP.NET Validation controls such as RequiredFieldValidator, CompareValidator, RangeValidator, RegularExpressionValidator, CustomValidator and ValidationSummary. 

These controls are very easy to hook up with other ASP.NET controls, and if properly configured they check input for possible errors, and display error messages to notify the user. There are lots of articles available on how to use the these controls, the ASP.NET Quickstart articles are really good too.

Validation Controls

Validating Form Input Control

[video] How do I: Use Validation Control in ASP.NET


ASP.NET AJAX ValidatorCallout

ValidatorCallout is an ASP.NET AJAX extender that enhances the functionality of existing ASP.NET validators.

Validator Callout demonstration

[video] How Do I: Use the ASP.NET AJAX ValidatorCallout Extender
Configuring this one is also time consuming and has to be done for each input controls.

ASP.NET AJAX Futures: Validators

The Futures release provides a number built-in validation controls:

  • requiredFieldValidator. Checks that data was entered.
  • typeValidator. Checks the type of the data, such as Number.
  • rangeValidator. Checks the input value between an upper and lower bound.
  • customValidator. Defines a custom expression handler.
  • regexValidator. Checks the data using a regular expression. The regular expression value must be delimited with "/" characters.


Subsonic Validation

SubSonic has one tier of validation - based on your database Schema. Kevin details how to make use of SubSonic's out of the box solution and how to customize it to emulate Rails/Django-like model validation. Read more.

Validation Everywhere (CodePlex)

Project Validation Everywhere´s purpose is to create a framework for declarative validation, so you can use the same validation logic through all the different environments that your Business Layer might be running against.
This project started mainly because of NMVP project (NMVP Project). I do a lot of MVP UI´s, and they really help in the direction of creating UI unit tests. One part of the UI that is overlooked in the testing is the validation since it´s done by ASP.Net and it´s validators.


Web Client Validation Bundle

The guidance in this bundle is designed to help you streamline the end-user experience of your web applications by utilizing ASP.NET AJAX to invoke server-side validation. Additionally you will find guidance on how to improve maintainability of your applications by reusing domain object validations across multiple screens, applications and tiers. You'll also find a set of guidelines on how to perform security validation in order to protect your sites from SQL Injection, Cross-Site scripting, etc. Like the Contextual Autocomplete Bundle, this guidance is applicable for both WCSF and standard ASP.NET non-WCSF based solutions.


Enterprise Library 3.0 Validation Block

The Enterprise Library Validation Application Block provides a library of classes, called validators, that supplies the code for validating .NET Framework data types. For example, one validator checks for null strings and another validator checks that a number falls within a specified range.

There are three ways to perform validation within the application block, and to create rule sets. They are:

  • Using configuration
  • Using attributes
  • Using code

In addition, the Validation Application Block includes adapters that allow you to use the application block with the following technologies:

  • Windows Forms
  • Windows Communications Framework (WCF)

Validation Application Block in Enterprise Library 3.0 - Using Validation Facade Class - Part I

Validation Application Block in Enterprise Library 3.0 - ValidationFactory Class - Part II

Validation Application Block in Enterprise Library 3.0 - Ruleset


.NetTier Validation Rule Engine


One of the most powerful features that .netTiers provides to manage the integrity of your data is the Entity Rule Engine. This implements IDataErrorInfo in the EntityBase.generated.cs class. It provides the framework for managing entity business rules and custom error information that a user interface can bind to. Controls such as the DataGridView automatically detect this interface and provide error icons along with descriptions about the error.
There are several properties that assist you in managing your business rules. There are several built in validators ready to use out of the box.

  • NotNull - Determines the if the database column accepts null values.
  • StringMaxLength - Compares against the column width for the property.
  • StringRequired - Determines if the column allows empty string entries.
  • MaxWords - Determines whether the property has exceeted the maximum number of words
  • RegexIsMatch - Determines whether current property matches the regular expression
  • LessThanOrEqualToValue - Less than or equal to current value of property
  • LessThanValue - - Less than current value of property
  • EqualsValue - Equals current value of property
  • GreaterThanValue - Greater than current value of property
  • GreaterThanOrEqualToValue - Greater than or equal to current value of property
  • CompareValues - Compares values of T using a comparer
  • InRange - Ensures T is within a min and max of a Range using a Comparer.



Here we have identified a handful amount of Validation Framework, it is true that all of them are very powerful and very well done.

Posted on Sunday, December 16, 2007 2:12 AM | Back to top

Comments on this post: Different ways of Validating ASP.NET Forms

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © Shahed Khan | Powered by: