Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
636 views
in Technique[技术] by (71.8m points)

asp.net - How to validate dynamically created control?

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...