I am trying to upgrade a straight ASP project into .NET, but I am new at
..NET, and there seem to be so many different ways to do things. I am new to
..NET and need some guidance as to which approach to take.
My application is to collect answers to an indeterminate number of
questions, which are defined in a database. The definition includes the
question content, type of control and validation for the data. In ASP, the
application called a function for the appropriate type of control to return
the html controls, and the validation details were included as part of the
control names. Validation was all server-side.
I can think of at least 2 ways that (if it works the way I think it does) to
do this in .NET:
1) Create a hard-coded Repeater control, which would include in the item
template all the possible control and validator types, making them all not
visible or not enabled. Then in the OnDataBinding (if this is the right
place), determine which control and validator(s) are needed for each
question, and enable and/or make visible the appropriate ones. I have not
tried this yet (it only just occurred to me), but it would take advantage of
the Repeater to build the page, and it may be easier to program data entry
into the answers database with it.
2) Do it the way the ASP page was built, and create all the controls and
validators dynamically at run-time, adding them to a Placeholder control.
This is what I’ve been working on, but I can’t seem to get any of the
validators working, so I thought maybe this was the wrong approach. And
maybe there is a performance issue with building the controls dynamically,
too.
Can anyone give recommendation on which approach to pursue? Which would be
easier, and whether there are performance issues with either one? Or maybe
there is a completely different way that I have not thought of.