Paul,
When you add a control dynamically, you have to add it to another control.
In the case of what you're trying, you should be using a placeholder
control.
Put the placeholder on your page where you want the user control to appear.
Then add your dynamic control to the placeholder.
Placeholder1.Controls.Add(MyControl)
If you'd like some working examples I have a few available on my website,
www.aboutfortunate.com, Just click on the "Code Library" link at the top and
then type "Dynamic Control" into the search text box that will appear and
you'll have a few examples.
--
Sincerely,
S. Justin Gengo, MCP
Web Developer / Programmer
www.aboutfortunate.com
"Out of chaos comes order."
Nietzsche
"PJ6" <no****@nowhere.net> wrote in message
news:O0**************@TK2MSFTNGP15.phx.gbl...
I need to add a user control in code, not through the designer. For some
reason it just doesn't show up. Is there some initialization method I need
to call for the control before attemptin to add it?
Paul
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Me.Controls.Add(New WebUserControl3)
End Sub