Label lb = new Label();
lb.Text = "label text";
Page.Controls.Add(lb);

解决方案 »

  1.   

    当然可以了,例如动态生成Label和TextBox :
    System.Web.UI.WebControls.Label tempLabel = new Label();
    System.Web.UI.WebControls.TextBox tempBox = new TextBox();
    this.Panel1.Controls.Add(tempLabel);
    this.Panel1.Controls.Add(tempBox);
      

  2.   

    或是:
    System.Web.UI.HtmlControls.HtmlForm  form=(HtmlForm)this.FindControl("Form1");
    System.Web.UI.WebControls.Label tempLabel = new Label();
    form.Controls.Add(tempLabel );
      

  3.   

    位置的定位可以设置控件的Attributes属性,例如:
    System.Web.UI.HtmlControls.HtmlForm  form=(HtmlForm)this.FindControl("Form1");
    System.Web.UI.WebControls.TextBox textbox = new TextBox();
    textbox.Attributes["style"]="position:absolute;top:1000px;left:2000px";
    form.Controls.Add(textbox);