ASP.usercontrols_basicpanel_ascx myControl = new ASP.usercontrols_basicpanel_ascx();
odujosh wrote:Heres a better way: ASP.usercontrols_basicpanel_ascx myControl = new ASP.usercontrols_basicpanel_ascx();Where user control is located:~/usercontrols/basicpanel.ascx
Hmm - works for me just fine Sven.
I add the instantiated control to an area on the page, for example:
ASP.controls_matrixcell_ascx matrixCell = new ASP.controls_matrixcell_ascx(); Panel1.Controls.Add(matrixCell);
great solution odujosh!
This is an old thread, but...
I think odujosh's method works with a Web Application Project, or a precompiled web site. It does not work however work with the VS2005 Web Site model.
I think, anyway, my memory's a bit foggy on this.
Actually, I'm using the Web Site model.
EDITED TO ADD:
While you can instantiate your user control from a page's code-behind file using the ASP.controls_controlname_ascx way, you cannot do this from an ordinary c# class, as the ASP namespace is not available there.