Click here to Skip to main content
13,901,646 members
Click here to Skip to main content
Add your own
alternative version

Tagged as


60 bookmarked
Posted 14 Oct 2008
Licenced CPOL

Client-side validation using Validation Application Blocks

, 4 Mar 2014
Rate this:
Please Sign up or sign in to vote.
Implementing client-side validation using Validation Application Blocks.

Table of Contents



Enterprise Validation application provides us a ready made framework by which we can implement dynamic validation easily in our projects. In case you are not aware of the basics, you can watch my 20 minutes exclusive video on it here.

By using Enterprise Validation Blocks, you can create validation in a dynamic fashion and the validations can be invoked depending on the user logged in. Now let’s understand one of the biggest drawbacks of the validation blocks and let’s see how we can address that.

I have been writing and recording videos on Design Patterns, UML, estimation, and a lot more, you can see my work here. If you think in any way that I should improve, please email me with suggestions at

Other Application Blocks

  • Validation application blocks: This article explains the 16 steps you need to perform to do validations using VAB: Validation application blocks.
  • Dynamic validation: This article explains how to build dynamic validation on a scenario basis: Dynamic validation.
  • Policy application blocks: This article talks about how to implement a plug and play mechanism using Policy application blocks: Policy application block.
  • Logging application block: This article explains the five basic steps for how to use logging application blocks: Logging application block.
  • Data application: This article talks about the four steps you need to implement data application blocks: Data application block.
  • Exception application block: This application talks about how we can use exception application blocks to log exceptions from a project: Exception application block.
  • Unity application block: This application talks about the Unity Application Block in DI and IOC: Unity application block.
  • UIP block: This article talks about reusable navigation and workflow for both Windows and Web using Microsoft UIP blocks: UIP block.


The biggest drawback with validation application blocks is it does not generate client code. Another way to put it is that all the validation happens on the server side. From my perspective, I think the application block developers have done it right. I mean they have defined a generic server side framework and left the implementation of the client side validation to the respective clients like Windows, ASP.NET, etc.

Broader Level Solution

So how do we solve the problem? You can Google all you want and you will not find an easy way out for this. You need to develop your own adapter. That means you need to develop an adapter which will read the rules from the validation blocks API and create an ASP.NET client side validator like required field, not null, etc.

If you find a better solution, do email me at

The Actual Code

OK, now that we know the problem, let’s see how we can solve it. If you have gone through the video given on the top, you will understand that all the validation is stored in a web.config file. Somehow we need to browse through the web.config file to get those validations. Once we get the validation, we can then create ASP.NET validators depending on the validations present in the web.config file.

If you look at your web.config which has validators defined using the validation application block, it would look something as shown below. All validations are enclosed inside the validation tag. It’s a four step process to browse to get the validation.

  • Step 1: Using the configuration source, get the validation settings.
  • Step 2: Using the validation settings, get all the ruleset from the validation tag.
  • Step 3: From the rule set, get the rule set data collection.
  • Step 4: Browse through the rule set data and generate the corresponding ASP.NET validators.

Click to enlarge

Below is the code for the above steps:

Click to enlarge

In the final step, we browse through the validator collection and generate the ASP.NET validators. You can use the type name to see which validator type it is. Using RangeValidatorData, you can get the details of the validator data and you can generate the ASP.NET validators accordingly.

Click to enlarge

There are ranges of different validators provided in the validation application blocks. Depending on the type, you can create the corresponding type of ASP.NET validator at the client side. You can also generate Windows validators accordingly.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

You may also be interested in...


Comments and Discussions

GeneralAlternative Pin
Kuldip Rindani13-Aug-09 1:39
memberKuldip Rindani13-Aug-09 1:39 
Generalgood outline Pin
Donsw28-Jan-09 13:01
memberDonsw28-Jan-09 13:01 
QuestionCode? Pin
glacierdigital26-Oct-08 5:45
memberglacierdigital26-Oct-08 5:45 
GeneralImages are blurry Pin
Todd Smith23-Oct-08 18:40
memberTodd Smith23-Oct-08 18:40 
GeneralRe: Images are blurry Pin
Shivprasad koirala23-Oct-08 21:31
memberShivprasad koirala23-Oct-08 21:31 
GeneralRe: Images are blurry Pin
Nish Nishant24-Oct-08 2:26
sitebuilderNish Nishant24-Oct-08 2:26 
GeneralRe: Images are blurry Pin
RuslanCanada24-Oct-08 11:05
memberRuslanCanada24-Oct-08 11:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web05 | 2.8.190306.1 | Last Updated 5 Mar 2014
Article Copyright 2008 by Shivprasad koirala
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid