Does anyone have any insight on how to systematically generate ASP.NET code for WebControls objects?

I would love the ability to take the following following
Code:
Dim lblTest As New Label
        lblTest.ID = "lblTest"
        lblTest.Text = "Some Text Here"
        lblTest.CssClass = "myCSSClass"
Then have a function that would generate:
Code:
<asp:Label id="lblTest" runat="server" CssClass="myCSSClass" Text="Some Text Here" />
I know I can make the function output the desired result, but it just seems like there would be functionality similar to RendorControl() but instead of generating the HTML it would generate the ASP.NET.

Thanks