Actually, here's a revised description of the issue:
I have two user controls, each of which sits in a directory called
"App_Controls" in an ASP.NET 2.0 site. When I try dynamically loading Control
#2 to a placeholder in Control #1, I cannot get a strongly typed reference to
that control, because the Type "App_Controls_ctlApplicationHome" is not
defined.
Does that make sense?
(to answer your question, I'm a C# developer working on a VB.NET project,
hence the schizophrenic coding)
"tdavisjr" wrote:
Ryan wrote: I'm a lot confused when using user controls in ASP.NET 2.0. How do I cast a
varaible to the type of a user control... for example:
Me.PlaceHolder1.Controls.Add(Page.LoadControl("~/App_Controls/ctlApplicationHome.ascx"))
' now, this doesn't work... why?
Dim apl As App_Controls_ctlApplicationHome = Me.PlaceHolder1.Controls(0);
Dim apl As App_Controls_ctlApplicationHome =
CType(Me.PlaceHolder1.Controls(0), App_Controls_ctlApplicationHome)
That should do it.
Just curious, what .NET language are you using? It looks like VB but I
notice you have a semi-colon at the very end of your last line of code.
:)