System.Web.UI.WebControls.WebControl”的限定符访问保护成员“System.Web.UI.WebControls.WebControl.WebControl()”;限定符必须是类型“MetaBuilders.WebControls.ComboBox”(或者从该类型派生)的怎么解决?
部分代码如下:namespace MetaBuilders.WebControls 
{   

[
    Designer(typeof(MetaBuilders.WebControls.ComboBoxDesigner)),//实现设计需要服务类
ValidationProperty("Text"), //标识元素属性的类    
]
public class ComboBox : System.Web.UI.WebControls.ListControl, IPostBackDataHandler, INamingContainer 
    { public ComboBox() : base() {}
..................
.............  
        private WebControl container;
        private WebControl button;
        private TextBox text;     
........protected override void CreateChildControls() 
        {
            container = new WebControl(); //出现错误
            container.ID="container";
this.Controls.Add( container );
            
text = new TextBox();
text.ID = "Text";
text.Attributes["autocomplete"] = "off";
container.Controls.Add( text );
text.TextChanged += new EventHandler( this.raiseTextChanged );
            
button = new WebControl(); //出现错误
button.ID = "Button";
container.Controls.Add( button );
}
怎么解决?

解决方案 »

  1.   

    MSDN上提示这样,.
    // CS1540.cs
    public class Base
    {
       protected void func()
       {
       }
    }public class Derived : Base
    {
       public static void test(Base anotherInstance)
       // the method declaration could be changed as follows
       // public static void test(Derived anotherInstance)
       {
          anotherInstance.func();   // CS1540
       }
    }public class Tester : Derived
    {
       public static void Main()
       {
          Base pBase = new Base();
          // the allocation could be changed as follows
          // Derived pBase = new Derived();
          test(pBase);
       }
    }
      

  2.   

    虽然派生的 class 可以访问其基类的受保护成员,但它无法通过基类的实例这样做。
    倒了
      

  3.   

    初始化 WebControl 类的新实例。重载列表
    初始化表示 Span HTML 标记的 WebControl 类的新实例。[Visual Basic] Protected Sub New()
    [C#] protected WebControl();
    [C++] protected: WebControl();
    [JScript] protected function WebControl();
    使用指定的 HTML 标记初始化 WebControl 类的新实例。[Visual Basic] Public Sub New(HtmlTextWriterTag)
    [C#] public WebControl(HtmlTextWriterTag);
    [C++] public: WebControl(HtmlTextWriterTag);
    [JScript] public function WebControl(HtmlTextWriterTag);
    使用指定的 HTML 标记初始化 WebControl 类的新实例。[Visual Basic] Protected Sub New(String)
    [C#] protected WebControl(string);
    [C++] protected: WebControl(String*);
    [JScript] protected function WebControl(String);
      

  4.   

    更改成container = new WebControl(HtmlTextWriterTag.Div);就可以了