我的控件“此处不允许,因为它不扩展类“System.Web.UI.UserControl””
所以我还有另一个面条刮板(无论如何对我来说)。
我正在尝试在 CMS 中创建自己的自定义控件,但我只有部分源代码(即供应商向我提供的示例)。基本上,我创建了一个名为 DataDefinitionContent
的类,它扩展了 ControlBase
。现在,从我从元数据中获得的信息来看,ControlBase
扩展了 UserControl
,所以我本以为这会毫无戏剧性地运行。谁能解释一下为什么这对我不起作用?
我的班级:
public partial class DataDefinitionContent : ControlBase, ICustomControl<DataDefinition>
{
... Stuff
}
ControlBase:
using System;
using System.Web.UI;
namespace CMS.Web
{
public class ControlBase : UserControl
{
... Stuff
}
}
我的 ascx 文件:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="DataDefinitionContent.ascx.cs"
Inherits="CMS.Admin.WebUI.CustomControls.DataDefinitionContent, CoA.Admin.WebUI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" %>
我收到的错误:
解析器错误消息: 'CMS.Admin.WebUI.CustomControls.DataDefinitionContent, CoA.Admin.WebUI,版本=1.0.0.0, 文化=中立,PublicKeyToken=null' 这里不允许,因为它确实如此 不延长班级 'System.Web.UI.UserControl'。
第 1 行: <%@ 控制语言="C#" AutoEventWireup="true" CodeBehind="DataDefinitionContent.ascx.cs"
So I have another noodle-scratcher (for me anyway).
I'm trying to create my own custom control in a CMS I only have partial source code for (i.e. samples the vendor has supplied to me). Basically I have created a class called DataDefinitionContent
which extends ControlBase
. Now, from what I can garner from the metadata, ControlBase
extends UserControl
, so I would have thought this would run without a drama. Can anyone shed any light on why this might not be working for me?
My Class:
public partial class DataDefinitionContent : ControlBase, ICustomControl<DataDefinition>
{
... Stuff
}
ControlBase:
using System;
using System.Web.UI;
namespace CMS.Web
{
public class ControlBase : UserControl
{
... Stuff
}
}
My ascx file:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="DataDefinitionContent.ascx.cs"
Inherits="CMS.Admin.WebUI.CustomControls.DataDefinitionContent, CoA.Admin.WebUI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" %>
The error I'm getting:
Parser Error Message:
'CMS.Admin.WebUI.CustomControls.DataDefinitionContent,
CoA.Admin.WebUI, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null'
is not allowed here because it does
not extend class
'System.Web.UI.UserControl'.Line 1:
<%@ Control Language="C#"
AutoEventWireup="true" CodeBehind="DataDefinitionContent.ascx.cs"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
当扩展 UserControl 类的类的名称不是 ASP 包含中使用的名称时,我收到此错误。我更改了类名并重新部署了解决方案。问题已解决。
I was getting this error when the name of the class that was extending the UserControl class was not the name used in ASP inclusion. I made the change to the class name and redeployed the solution. The problem was fixed.
就我而言,由于缺少命名空间,因此引发了错误。
In my case error was thrown, because of missing namespace.
尝试将您的部分课程放入
Try putting your partial class in