Monday, January 11, 2010

Adding a UserControl to a Placeholder Dynamically

So I was trying to dynamically generate my page by newing a UserControl and adding it to a Placeholder on Page_Load:

ucSelectMed ucMySelectMed = new ucSelectMed();

Ran the project, nothing was on the page.

Was really confused because the following works:

TextBox tb = new TextBox();

Anyway, what was needed is:

ucSelectMed ucMySelectMed = (ucSelectMed)LoadControl("ucSelectMed.ascx");

No comments:

Post a Comment