Asp – How to validate dynamically created control

ajaxasp.net

I have an asp.net page, some of its controls are created dynamically, these controls are one of the following; textbox, calendar, or dropdownlist.

These controls in some cases, should be validated based on flag read from db?

Is there any way to validate
dynamically created controls?

Best Answer

Basically you will need to create your validators via code and attach them to the dynamically created controls via code too. The page will then render with your validators in the page for you.

If validation requires a flag to be read from the db then perhaps use a custom validator which will allow you to set up your specific logic on both the client and server for your specific validation requirements. You don't have to provide client validation if you don't want to.