I'm trying to dynamically load a user control using on the .NET
framework (not Visual Studio).
The control was designed in Visual Studio and is named: Disable.ascx
The first line is:
<%@ Control Language="c#" className="Disable1" src="Disable.ascx.cs" %>
The host page for this control is named UserControl.aspx.
The first 2 lines are:
<%@ Reference control="Disable.ascx" %>
<%@ Page language="c#" src="UserControl.aspx.cs" %>
The code-behind for the host page is called: UserControl.aspx.cs
The User Control is loaded from this code in the code-behind:
private void Page_Load(object sender, System.EventArgs e)
{
Disable1 uc = (Disable1) Page.LoadControl("Disable.ascx");
Panel1.Controls.Add(uc);
}
I always get this error when I try to bring up the host page:
CS0246: The type or namespace name 'Disable1' could not be found (are
you missing a using directive or an assembly reference?)
and it highlights this line of code:
Disable1 uc = (Disable1) Page.LoadControl("Disable.ascx");
How can I get it to dynamically load the user control from the code
behind file of the host page?
Thanks,
Eric Engler