I'm trying to add a custom user control to a Panel in a visual web part in Sharepoint 2010, with the following lines of code:
MyUserControl userControl = new MyUserControl();
MainContentPanel.Controls.Add(userControl);
However, my user control fails to load/render. The above code is triggered by clicking a link button.
Am I missing something, or is it just not possible to do it this way?