Last post Mar 29, 2012 06:42 PM by kprashu
Nov 09, 2011 08:22 PM|teamdotnet|LINK
In the donations management application at Aidmatrix, we use dynamic controls on the asp.net forms. It did not support on-the-fly validations based on the user input. This effects the usability eg. the user has to enter all the required data fields even though
it is not applicable based on his input. The other downside is this results in incorrect data since validation did not happen at runtime - eg. departure date for a travel is later than the
Background of the architecture that dynamically loads the controls on the page -
The control definition is all stored in the database and a class library with an interface handle the display of all type of controls on the asp.net page.
Database definition includes layout (caption, row, col, span, visibility etc), css, control type(text, dropdown, check box etc), databindings, validations (required, range, date) and various attributes, extender controls etc. Asp.net page retrieves the defition
of the controls on the page based on the role and certain other business criteria. All the css, layout and validations are applied on the controls as it would happen at design time but this is at run time.
When the user submits the form, data in the controls is collected from the properties using reflection and entered in the database. Key thing here is to use the unique ID of the control and hence it is very important to name the controls. we use prefixes to
handle the form name, section name, type of control (tb for text box, cb for combo box) etc. The more detailed the better for troubleshooting etc.
Now, how the dynamic custom validation works?
Step 1 - add a non-visual custom validator control
A new custom validator control is added to the asp.net form (defined in the database). This would be a non-visual control. The new custom
validator is implemented in the class library by setting up the required attributes defined in the database. This mainly includes controlToValidate,
clientValidationFunction, Error Message, ValidationGroup etc.
Working solution -
Departure date and a return date can be compared
now to make sure they are valid. Any field can be made mandatory based on the
user’s input in another field on the same form at run time.
Nov 29, 2011 05:53 PM|Pekanbaru|LINK
thanks sir... I am
a beginner so
..:: Ban Terbaik di Indonesia GT Radial ::..
Jan 31, 2012 07:01 PM|guozhang|LINK
I'd like to know your actual solution on adding the "non-visual" custom validator control to an asp.net page that has dynamically added controls. I am facing the same situation where I am able to dynamically add custom controls of different kinds based on
configuration settings on the database side to an asp.net page but not able to come up with a good solution to add validation controls to these dynamically added server controls.
It would be really great if you could post your solution on adding custom validation controls to work with dynamically added controls.
Mar 29, 2012 06:42 PM|kprashu|LINK
How did you implement the dynamic custom validator? I am trying to do something similar (load the validation error messages from the database and create the validation controls at runtime).
Please provide me additional details on how you implemented it or please email me at