I have an aspx page I have already built using several ascx user controls.
I would like to display that page in a panel on another page.
The reason I did not add the user controls via code to the panel is that
when I try code like
Me.Panel1.Visible = True
Me.Panel1.Controls.Clear()
Dim MyHeader As New System.Web.UI.UserControl
MyHeader.LoadControl("header.ascx")
Me.Panel1.Controls.Add(MyHeader)
I get the error: The virtual path '/header.ascx' maps to another
application, which is not allowed. And I can find no way to get away from
the error message.
However, on a second look, I discovered that code like
Dim uc1 As Control = Page.LoadControl("header.ascx")
Me.Panel1.Controls.Add(uc1)
does not produce the error. so I can use the method you suggest. But now I
am curious as to why the first block of code produces the error and the
second doesn't.