I want to create a user control DerivedUserControl.ascx
that derives form another user control BaseUserControl.ascx
. The base user control derives from System.Web.UI.UserControl
as required. These user controls are defined in different folders. Because I'm using a Visual Studio 2010 Web Site project (I'm not able to switch to Web Application project), these user controls are not defined inside a namespace.
My problem is that when I try to compile the project the base class of the derived user control cannot be resolved (obviously because the compiler doesn't know what .ascx file defines the base class). Is there a way resolve this issue?
I tried everything I could imagine, without success. Any help would be greatly appreciated.
BaseUserControl.ascx
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="BaseUserControl.ascx.cs" Inherits="BaseUserControl" %>
BaseUserControl.ascx.cs
public partial class BaseUserControl : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
DerivedUserControl.ascx
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="DerivedUserControl.ascx.cs" Inherits="DerivedUserControl" %>
DerivedUserControl.ascx.cs
public partial class DerivedUserControl : BaseUserControl
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
Error
The type or namespace name 'BaseUserControl' could not be found