我有一个继承自
我需要控件继承自
当我这样做时,Visual Studio会给出一个编译错误:
请确保此代码文件中定义的类与“inherits”属性匹配,并且它扩展了正确的基类(例如Page或UserControl)。
如何让我的控件从Control而不是UserControl继承?
系列
这个问题是Stackoverflow持续系列“模板化用户控件”中的一个。
UserControl
的ASP.net控件:
文件1:
public partial class Controls_AllocationDuplicate : System.Web.UI.UserControl
文件 2:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="AllocationDuplicate.ascx.cs" Inherits="Controls_AllocationDuplicate" %>
我需要控件继承自
Control
而不是UserControl
。
File.aspx.cs (更改后):public partial class Controls_AllocationDuplicate : System.Web.UI.Control
File.aspx (未更改):
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="AllocationDuplicate.ascx.cs" Inherits="Controls_AllocationDuplicate" %>
当我这样做时,Visual Studio会给出一个编译错误:
请确保此代码文件中定义的类与“inherits”属性匹配,并且它扩展了正确的基类(例如Page或UserControl)。
如何让我的控件从Control而不是UserControl继承?
系列
这个问题是Stackoverflow持续系列“模板化用户控件”中的一个。