在Form中添加一个Panel控件,然后把TextBox空间添加到Panel中。

解决方案 »

  1.   

    protected System.Web.UI.WebControls.Panel Panel1;

    private void Page_Load(object sender, System.EventArgs e)
    {
    if (!Page.IsPostBack)
    {
    TextBox tb = new TextBox();
    tb.ID = "text";
    tb.Text = "aaa";
    this.Panel1.Controls.Add(tb);
    }
    }
      

  2.   

    是不是要添加多个控件阿?如果是,使用Table就是了。
      

  3.   

    table怎么用啊
    我最开始就用得table,可是总有问题
    我将table设成runat=server,然后做,可是和我刚才做的问题一样
      

  4.   

    Table tbl = new Table();TableRow tr = new TableRow();
    TableCell tc = new TableCell();
    TextBox box = new TextBox();
    box.ID = "DDD";
    tc.Controls.Add(box);
    tr.Cells.Add(box);
    tbl.Rows.Add(tr);按这个下去就是了。添加textbox控件的时候,可以不预先添加Panel。
    通过这个代码可以实现。
    this.Controls[1].Add(box);