VALIDATION MACHINE FOR ADMINISTRATORS
Suppose we have a very huge online project in which contains the task of making a whole ERP solution online.Now this task will require hundreds of aspx pages involving various modules like purchase,production,vendor ,product, etc .Handling such huge project will have its on headaches when the parameters change every now and then.For example the upper and lower limits of certain products get changed.Some of the fieldsthat were mandatory become non essential and some non essential ones become essential.There may also arise matters of concern then the whole regular expression needs to be changed.
During these times of change the coder has to be employed to go into each individual page and change thevalues of the validators, either enable,disable them,change their types,ranges or at times changing the whole regular expression.
During these times we this validation machine becomes a boon since it comes to rescue by enabling the user to change the whole property of your webpage validators by using a single interface.
All you need to do is place the following code either on load of the page and run it once(remember only once) , so that all the details of your validation controls present in your page are stored in the database.So now after wards from the User Interface you get all the details regarding your page's validation controls in editable format.
You can change the properties of the validation control from this interface and similarly all the validation controls on your web page change their behavior.
In the example project below I have taken a page Page1.aspx , in which there exits a panel named Panel1 inside which there are two textboxes (Textbox1 and Textbox2 ) along with three validators namely
RequiredFieldValidator1,RangeValidator1 and ValidationSummary1.
Now i have specifically put a button here and on it click event i called up
Dim objclsValidation4all As New clsValidation4all
objclsValidation4all.AddValidationControls("Panel1", Panel1)
note: for nowkeep the validation controls Enabled property to false, else the page will not be posted back on button Click.
After running this page , run the AdminInterface.aspx , in which lists down the panel1 in a dropdownlist and a gridview below showing the validators in the gridview below.On selecing the validation controls from the gridview it would in turn open its corresponding gridview wherein you can change the validtors properties.
Note that according to the validators selected from the first grid, i.e RangeValidator,RequiredField Validator or RegularExpression validator the girdView2 changes.
We also have the option of disabling the need validation control by unchecking the flag in the Gridview2, therby disabling the validation control totally. Thus , We can keep on adding new pages and alongside the validation control in those pages canbe manipulated from the AdminInterface.Everytime the page loads the page will communicate with the database(in this case ValidationDatabase ) and fetch the properties for the validation controls.So go on adding as many panels or server controls along with their validation controls and control them as and when you desire !!
Hence like this we can easily automatize the working of the validation controls in our website.Thus without having the need to manually wade through the webproject's Solution Explorer and selecting the required page and changing the validation control values we can do it from the AdminInterface.
VALIDATION FOR ALL Project files
Included :
aspx pages:-
1.Page1.aspx
2.AdminInterface.aspx
class files : -
1.ClsReverseUtility.vb -->
contains method :AddValidationControls(ByVal InternalGroupName As String, ByVal Ctl As Control)
whose functionality is to traverse through all the validation controls inside the Control specified by you.As in code above where we have take "Panel1".
2.clsValidation4all.vb
SetValidationControls(ByVal ValidationControlName As String, ByVal ValidationControlType As String)
Note we set these values into the database using function specified in this class.
DATABASE
=========
3 Tables.
1.MasterViewTable -------------------------
ValidationKeyId (PK)
InternalGroupName
UserShownName
2.ServerControlTable
---------------------------
ServerControlKeyId
ValidationKeyId
ControlId
Flag
UserFlag
UserShownControlId
UserFlag
3.ValidationControlTable
--------------------------------
ValidationControlKeyId
ServerControlKeyId
ValidationControlName
ValidationUserShownName
ValidationType
Value1
Value2
ErrorMessage
Flag
UserFlag
ServerControlKeyId
Attachments
 Page 1
 AdminInterface step 1
 AdminInterface step 2
 AdminInterface step 3
 Page1Source Code of ValidationMachine (472-24752-ValidationForAll.zip)
|
| Author: siva | Member Level: Gold | Revenue Score:   |
Hi, Its really nice. I would like learn such type of things.
It will be greatful for me to send the files.
Thanks Rakesh, Siva Sreenath
|