I have an ASP.net control that inherits from UserControl
:
File 1:
public partial class Controls_AllocationDuplicate : System.Web.UI.UserControl
File 2:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="AllocationDuplicate.ascx.cs" Inherits="Controls_AllocationDuplicate" %>
I need the control to inherit from Control
, rather than UserControl
:
File.aspx.cs (changed):
public partial class Controls_AllocationDuplicate : System.Web.UI.Control
File.aspx (not changed):
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="AllocationDuplicate.ascx.cs" Inherits="Controls_AllocationDuplicate" %>
When i do this, Visual Studio gives a compile error:
Make sure that the class defined in this code file matches the 'inherits' attribute, and that it extends the correct base class (e.g. Page or UserControl).
How can I have my control inherit from Control
rather than UserControl
?
Series
This question is one in the ongoing Stackoverflow series, "Templating user controls":