Is there a reason why you can NOT create the controls dynamically in code?

Rendering them in a html string seems like bad practice to me.