T
Trillium
I need to build controls and their associated validators dynamically,
depending on requirements from a database query. The database provides the
text of the questions, the type of control needed (textbox, radio buttons,
etc), and validation for the control (required, number, string etc).
I am going about this by checking the control requirements for each record,
declaring a new control of the type needed, then adding it to a placeholder
with .Controls.Add(input control). Then I check the validation for the
control, and declare and create the appropriate validator type(s), and add
them to the placeholder and also Validators with
Page.Validators.Add(validator control).
The controls build ok, and some of the validators work, but not all. I
notice that, upon submit, the validators collection only has the ones which
are hard-coded into the html. So maybe the Page.Validators.Add is not
enough, and maybe this is part of the problem.
I am new at .NET, so I may be going about this in the wrong way. What am I
missing?
depending on requirements from a database query. The database provides the
text of the questions, the type of control needed (textbox, radio buttons,
etc), and validation for the control (required, number, string etc).
I am going about this by checking the control requirements for each record,
declaring a new control of the type needed, then adding it to a placeholder
with .Controls.Add(input control). Then I check the validation for the
control, and declare and create the appropriate validator type(s), and add
them to the placeholder and also Validators with
Page.Validators.Add(validator control).
The controls build ok, and some of the validators work, but not all. I
notice that, upon submit, the validators collection only has the ones which
are hard-coded into the html. So maybe the Page.Validators.Add is not
enough, and maybe this is part of the problem.
I am new at .NET, so I may be going about this in the wrong way. What am I
missing?