只要把控件NetMenu添加到当前控件列表就可以:this.Controls.Add(NetMenu);

解决方案 »

  1.   

    //我给你一段示例:
    //---------------------------------------
    //1、重写WebControl的CreateChildControls方法:protected override void CreateChildControls()
    {
    Controls.Clear();
    ClearChildViewState();
    BuildControlHierarchy();
    }//2、BuildControlHierarchy的实现
    private void BuildControlHierarchy()
    {
    // 建一个2行4列的表格
    Table t = new Table();
    t.ID="t";
    t.Font.Name = this.Font.Name;
    t.Font.Size = this.Font.Size;
    t.BorderStyle = this.BorderStyle;
    t.BorderWidth = this.BorderWidth;
    t.BorderColor = this.BorderColor;
    t.Width = this.Width;
    t.Height = this.Height;
    t.BackColor = this.BackColor;
    t.ForeColor = this.ForeColor;

    //表格行变量
    TableRow row;
    //单元格变量
    TableCell cell; // 添加一个表格行(第1行)--------------
    row = new TableRow();
    row.VerticalAlign=VerticalAlign.Top;
    row.Width=this.Width;
    cell = new TableCell();
             LinkButton lnbtnDelete = new LinkButton();
             lnbtnDelete.Text = "删除";         cell.Controls.Add(lnbtnDelete);         row.Cells.Add(cell);
             t.Rows.Add(row); // 把表格加入控件
    this.Controls.Add(t);
    }
      

  2.   

    非常感谢 triout(笨牛) & NoReady(亦正亦偏)