我1正在注册用户控件 :Control
web.config
<configuration>
<system.web>
<pages validateRequest="false">
<controls>
<add src="~/GenericControls/Toolbar.ascx"
tagName="Toolbar" tagPrefix="Vista" />
</controls>
</pages>
</system.web>
<configuration>
现在,因为我的“用户控件”是 a Control
,而不是 a UserControl
(为了支持模板),这会导致 Visual Studio 错误:
ASPNET:确保此代码文件中定义的类与“继承”属性相匹配,并且它扩展了正确的基类(例如 Page 或 UserControl)。
此错误的修复是您必须提醒 Visual Studio *control inherits from
Control`:
<%@ Page language="c#" Inherits="University.AspNet.Index"
CodeFile="Index.aspx.cs" CodeFileBaseClass="XXXXXX" %>
具有超级机密CodeFileBaseClass
属性。除了我没有使用Page指令外,我在 web-config 中注册了整个站点的控件:
<add src="~/GenericControls/Toolbar.ascx"
tagName="Toolbar" tagPrefix="Vista" />
我如何CodeFileBaseClass
从内部指定web.config
?
系列
这个问题是正在进行的 Stackoverflow 系列“模板化用户控件”中的一个: