Should dynamic asp.net controls be avoided at all costs?
In what situations should they be used?
What do you use as their replacement?
Should dynamic asp.net controls be avoided at all costs?
In what situations should they be used?
What do you use as their replacement?
1) Unnecessary complexity always should be avoided.
2) When they are necessary.
3) Lesser complicated options.
I mostly avoid them if a postback is required. Reconstructing them is a pain. When possible build them inside a <asp:repeater>
or other control which can be databound.
For rehydrating them on post back I use a DynamicControlsPlaceholder
It's great when you want to bring a control back with it's viewstate without having to reconstruct it yourself on each request.