【发布时间】:2012-09-01 18:08:07
【问题描述】:
我1 正在web.config 中注册一个用户控件 Control:
<configuration>
<system.web>
<pages validateRequest="false">
<controls>
<add src="~/GenericControls/Toolbar.ascx"
tagName="Toolbar" tagPrefix="Vista" />
</controls>
</pages>
</system.web>
<configuration>
现在,因为我的 “用户控件” 是 Control,而不是 UserControl(为了支持模板),这会导致 Visual Studio 错误:
ASPNET:确保此代码文件中定义的类与“inherits”属性匹配,并且它扩展了正确的基类(例如 Page 或 UserControl)。
这个错误的修复是你have to remind Visual Studio that the *controlinherits fromControl`:
<%@ Page language="c#" Inherits="University.AspNet.Index"
CodeFile="Index.aspx.cs" CodeFileBaseClass="XXXXXX" %>
具有超级机密CodeFileBaseClass 属性。除了我没有使用 Page 指令外,我在 web-config 中注册了 site-wide 控件:
<add src="~/GenericControls/Toolbar.ascx"
tagName="Toolbar" tagPrefix="Vista" />
如何在web.config 中指定CodeFileBaseClass?
系列
这个问题是 Stackoverflow 系列中的一个,“模板化用户控件”:
【问题讨论】:
-
出于兴趣,您的问题第一行引用的脚注 #1 在哪里?!
标签: asp.net user-controls templating