.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal

Home >> Articles >> .Net Framework >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Dynamic validation according to logged in user

Posted By:Shivprasad koirala       Posted Date: February 17, 2009    Points: 25    Category: .Net Framework    URL: http://www.questpond.com  

Dynamic validation according to logged in user


Many times we want certain set of validation to fire for some user and certain set of validation to fire for some other user. In the section we will see how we can achieve the same using Microsoft enterprise validation blocks.

I have been writing and recording videos on architecture, design patterns, UML, enterprise blocks etc. You can view all my videos on http://www.questpond.com/  . Any feedbacks do email me at shiv_koirala@yahoo.com 

The problem

There are times when you want validation according to the logged in user or customer. For instance in the below figure you can see we want different validation for both user. For one user we want that the customer code should be minimum 2 characters while for the other user we want it to be 5 characters.

Figure: - Logged in user

The Solution

Enterprise library helps us to solve this problem like a charm. To understand this article you need to once read basics of how to implement validation using VAB ( validation application blocks ). In case you are not aware of the basics you can read the same from my previous article http://www.dotnetspark.com/kb/312-16-steps-to-write-flexible-business-validation.aspx .

To fire validation according to logged in user is a two step process.

Step 1
First you need to define two different rule set according to customer. For instance you can see in the below figure we have defined two validation. The first validation checks if the customer code is minimum two length while the second validation checks if the customer code is five length.

Step 2:- In step 2 we just need to call the validation according to user logged in using the "Validation" static class. The validate function of the validation static class have two parameters one is the customer object and the other is the rule name. So depending on logged in customer you can fire the rules on fly.


 Subscribe to Articles


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend