基类包含字段’lbl’,但其类型(web.App_Code.CustomLabelControl)与控件类型(web.App_Code.CustomLabelControl)不兼容.
我以同样的方式完成了许多自定义控件,但是Hell这个错误让我很难.我有一个Web应用程序项目与App_Code目录中的下列类别在web.config中的类中的控件的tagprefix引用.现在我该怎么做?
Web.Config中
<system.web> <pages> <controls> <add namespace="web.App_Code" tagPrefix="CControls"/>...
<form id="form1" runat="server"> <div> <CControls:CustomLabelControl runat="server" OnClickText="Welcome" ID="lbl"> </CControls:CustomLabelControl> </div> </form>
类文件
namespace web.App_Code { public class CustomLabelControl : Control,IPostBackEventHandler,IPostBackDataHandler { private string _onClickText; public CustomLabelControl() { } public string OnClickText { get { return _onClickText; } set { _onClickText = value; } } public void RaisePostBackEvent(string eventArgument) { throw new System.NotImplementedException(); } public bool LoadPostData(string postDataKey,NameValueCollection postCollection) { throw new System.NotImplementedException(); } public void RaisePostDataChangedEvent() { throw new System.NotImplementedException(); } } }
试过这些
> The base class includes the field ‘btnLogin’,but its type (FoodOrder.App_Code.LinkButtonDefault) is not compatible
> http://support.microsoft.com/kb/919284
> The base class includes the field ‘ScriptManager1’,but its type (System.Web.UI.ScriptManager) is not compatible with the type of control (System.Web.UI.ScriptManager)