i1 am registering a user control Control
in web.config
:
<configuration>
<system.web>
<pages validateRequest="false">
<controls>
<add src="~/GenericControls/Toolbar.ascx"
tagName="Toolbar" tagPrefix="Vista" />
</controls>
</pages>
</system.web>
<configuration>
Now, because my "user control" is a Control
, rather than a UserControl
(in order to support templating), this causes the Visual Studio error:
ASPNET: 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).
The fix for this bug is that you have to remind Visual Studio that the *controlinherits from
Control`:
<%@ Page language="c#" Inherits="University.AspNet.Index"
CodeFile="Index.aspx.cs" CodeFileBaseClass="XXXXXX" %>
with the super-secret CodeFileBaseClass
attribute. Except i'm not using a Page directive, i'm registering the control site-wide in web-config:
<add src="~/GenericControls/Toolbar.ascx"
tagName="Toolbar" tagPrefix="Vista" />
How do i specify CodeFileBaseClass
from within web.config
?
Series
This question is one in the ongoing Stackoverflow series, "Templating user controls":
- How to add a Templating to a UserControl?
- How to inherit from Control, rather than UserControl?
- UserControl has IsPostBack, but Control does not
- UserControl does not have public property named ContentTemplate
- How do i specify CodeFileBaseClass from web.config?