I'm creating my first .net website using c#.
I was wondering what the best way is to set web controls dynamically. I've seen examples where controls are set in the aspx page and others where it is set in code.
Looking for advice as to why one is preferred over the other, or is it just a matter of choice?
This is a very broad question and the answer is mostly preference based.
For me, if I'm writing something without a lot of HTML, but and mostly functional back-end processing (or even heavily javascript based), I'll write a server control and create everything in code. If my output is heavily decorated HTML, then I will most certainly use a UserControl. There are several caveats that limit your ability to use the more beginner-friendly UserControl, including inclusion in a toolbox, export to a library, etc.