5,666,132 members and growing! (17,739 online)
Email Password   helpLost your password?
Platforms, Frameworks & Libraries » .NET Framework » General     Beginner License: The Code Project Open License (CPOL)

Dynamic validation according to logged in user

By Shivprasad koirala

Dynamic validation according to logged in user
C# (C# 1.0, C# 2.0, C# 3.0, C#), .NET (.NET, .NET 3.5, .NET 3.0, .NET 1.0, .NET 1.1, .NET 2.0, DotGNU), ASP.NET, ADO.NET, WCF, WPF, Ajax, Architect

Posted: 9 Oct 2008
Updated: 29 Oct 2008
Views: 4,392
Bookmarked: 23 times
Announcements
Loading...



Search    
Advanced Search
Sitemap
15 votes for this Article.
Popularity: 3.94 Rating: 3.35 out of 5
7 votes, 46.7%
1
1 vote, 6.7%
2
0 votes, 0.0%
3
1 vote, 6.7%
4
6 votes, 40.0%
5
Note: This is an unedited contribution. If this article is inappropriate, needs attention or copies someone else's work without reference then please Report This Article
Title:        C# validation according to logged in user
Author:      Shivprasad Koirala 
Email:       shiv_koirala@yahoo.com
Language:    C#
Level:       Beginner
Description: C# validation according to logged in user

Dynamic validation according to logged in user

Introduction

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.codeproject.com/KB/aspnet/Questpond.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.

 

License

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

About the Author

Shivprasad koirala


I am currently a CEO of a small E-learning company in India. We are very much active in making training videos , writing books and corporate trainings. You can visit about my organization at www.questpond.com and also enjoy the videos uploaded for Design patter, FPA , UML , Project and lot. I am also actively involved in RFC which is a financial open source madei in C#. It has modules like accounting , invoicing , purchase , stocks etc.
Occupation: Architect
Company: http://www.questpond.com
Location: India India

Other popular .NET Framework articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 2 of 2 (Total in Forum: 2) (Refresh)FirstPrevNext
General45 Articles that lot of writing....memberslemaryino21:36 25 Oct '08  
GeneralRocks.....memberBAIJUMAX21:37 9 Oct '08  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 29 Oct 2008
Editor:
Copyright 2008 by Shivprasad koirala
Everything else Copyright © CodeProject, 1999-2008
Web16 | Advertise on the Code Project