我的控件是“这里不允许的,因为它没有扩展类’System.Web.UI.UserControl’”

所以我还有另一个面条(对我而言)。

我正在尝试在CMS中创建自己的自定义控件我只有部分源代码(即供应商提供给我的样本)。 基本上我已经创建了一个名为DataDefinitionContent的类,它扩展了ControlBase 。 现在,从我从元数据中获取的内容, ControlBase扩展了UserControl ,所以我认为这将在没有戏剧性的情况下运行。 任何人都可以解释为什么这可能不适合我?


我的课:

 public partial class DataDefinitionContent : ControlBase, ICustomControl { ... Stuff } 

ControlBase:

 using System; using System.Web.UI; namespace CMS.Web { public class ControlBase : UserControl { ... Stuff } } 

我的ascx文件:

  

我得到的错误:

分析器错误消息:此处不允许使用’CMS.Admin.WebUI.CustomControls.DataDefinitionContent,CoA.Admin.WebUI,Version = 1.0.0.0,Culture = neutral,PublicKeyToken = null’,因为它不扩展类’System.Web。 UI.UserControl”。

第1行:<%@ Control Language =“C#”AutoEventWireup =“true”CodeBehind =“DataDefinitionContent.ascx.cs”

尝试将你的部分课程

 namespace CMS.Web 

当扩展UserControl类的类的名称不是ASP包含中使用的名称时,我收到此错误。 我对类名进行了更改并重新部署了解决方案。 问题得到解决。