基类包含字段’btnLogin’,但其类型(FoodOrder.App_Code.LinkBut​​tonDefault)不兼容

基类包括字段’btnLogin’,但其类型(FoodOrder.App_Code.LinkBut​​tonDefault)与控件类型(FoodOrder.App_Code.LinkBut​​tonDefault)不兼容。

ASPX:

  

LinkBut​​tonDefault:

 namespace FoodOrder.App_Code { public class LinkButtonDefault : LinkButton { protected override void OnLoad(System.EventArgs e) { Page.ClientScript.RegisterStartupScript(GetType(), "addClickFunctionScript", _addClickFunctionScript, true); string script = String.Format(_addClickScript, ClientID); Page.ClientScript.RegisterStartupScript(GetType(), "click_" + ClientID, script, true); base.OnLoad(e); } private const string _addClickScript = "addClickFunction('{0}');"; private const string _addClickFunctionScript = @" function addClickFunction(id) {{ var b = document.getElementById(id); if (b && typeof(b.click) == 'undefined') b.click = function() {{ var result = true; if (b.onclick) result = b.onclick(); if (typeof(result) == 'undefined' || result) {{ eval(b.getAttribute('href')); }} }}}};"; } } 

aspx.designer.cs:

 protected global::FoodOrder.App_Code.LinkButtonDefault btnLogin; 

有人可以解释我的错误吗?

我认为你有一个使用App_Code文件夹的循环引用。

MS建议使用两种方法进行修复: http : //support.microsoft.com/kb/919284

修改web.config以将元素设置为false(仅适用于小型应用程序)

要么

重新排序应用程序中的文件夹。 AKA – 将你的链接按钮类放在其他地方。