J
Jay Douglas
I have a set of pages that inherit from a base class in the App_Code folder.
The class looks something like:
public class MyBaseClass : System.Web.UI.Page
In various stages of the life cycle I need to add user controls to the page
control container. i.e:
protected override void OnInit(EventArgs e)
{
this.Controls.AddAt(0, myUserControl);
base.OnInit(e);
}
However, my user controls are not visible from the base class in App_Code
because of how ASP.NET 2.0 now compiles the projects. I've seen a few
suggestions on actually putting the .ascx file in the App_Code folder, but
this gives me a compile error of:
The file '/MyWebApp/App_Code/WebUserControl.ascx.cs' is in the special
directory 'App_Code', which is not allowed.
What is the solution for dynamically loading and adding user controls to the
page from a base class located in the App_Code folder?
The class looks something like:
public class MyBaseClass : System.Web.UI.Page
In various stages of the life cycle I need to add user controls to the page
control container. i.e:
protected override void OnInit(EventArgs e)
{
this.Controls.AddAt(0, myUserControl);
base.OnInit(e);
}
However, my user controls are not visible from the base class in App_Code
because of how ASP.NET 2.0 now compiles the projects. I've seen a few
suggestions on actually putting the .ascx file in the App_Code folder, but
this gives me a compile error of:
The file '/MyWebApp/App_Code/WebUserControl.ascx.cs' is in the special
directory 'App_Code', which is not allowed.
What is the solution for dynamically loading and adding user controls to the
page from a base class located in the App_Code folder?