象这样:Private Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Dim HeaderControl As Control = Page.LoadControl("/Controls/Header.ascx")
Page.Controls.Add(HeaderControl)Dim ContentControl As Control = Page.LoadControl("/Controls/Content.ascx")
Page.Controls.Add(ContentControl)Dim FooterControl As Control = Page.LoadControl("/Controls/Footer.ascx")
Page.Controls.Add(FooterControl)
End Sub
Dim HeaderControl As Control = Page.LoadControl("/Controls/Header.ascx")
Page.Controls.Add(HeaderControl)Dim ContentControl As Control = Page.LoadControl("/Controls/Content.ascx")
Page.Controls.Add(ContentControl)Dim FooterControl As Control = Page.LoadControl("/Controls/Footer.ascx")
Page.Controls.Add(FooterControl)
End Sub
<script language="C#" runat="server"> void Page_Load(Object sender, EventArgs E) { Page.Controls.Add(new HtmlGenericControl("hr")); Control c1 = LoadControl("pagelet7.ascx");
((Pagelet7CS)c1).Category = "business";
Page.Controls.Add(c1); Page.Controls.Add(new HtmlGenericControl("hr")); Control c2 = LoadControl("pagelet7.ascx");
((Pagelet7CS)c2).Category = "trad_cook";
Page.Controls.Add(c2); Page.Controls.Add(new HtmlGenericControl("hr")); Control c3 = LoadControl("pagelet7.ascx");
((Pagelet7CS)c3).Category = "mod_cook";
Page.Controls.Add(c3);
} </script><body style="font: 10.5pt 宋体"> <h3>以编程方式创建用户控件</h3></body>
</html>
http://aspalliance.com/399