Take the 2-minute tour ×

So, here's the scenario. I want to have a page that allows a user to add as many fields to a form and have a few validations to choose from for each field and save that to a database. On the page that would show their form, I would have a list of DTextbox(es) (class that I created to represent each field (Dynamic Textbox) that just has a string property) for each row in the database. I wanted to just add data annotations to the string property in each DTextbox in the list. There's two problems with that. One, at least not that I know of, there is no way to dynamically add data annotations like [Required] and [StringLength] to a property. Two, again not that I know of, there is no way to dynamically set what [StringLength]'s max and min values are.

So, my question is, what would be the best way to add validation to these textboxes?

share|improve this question
add comment


Your Answer



Browse other questions tagged or ask your own question.