public void AddMyControls()
 {
    TextBox textBox1 = new TextBox();
    Label label1 = new Label();
    
    // Initialize the controls and their bounds.
    label1.Text = "First Name";
    label1.Location = new Point(48,48);
    label1.Size = new Size (104, 16);
    textBox1.Text = "";
    textBox1.Location = new Point(48, 64);//制定你的位置
    textBox1.Size = new Size(104,16);
 
    // Add the TextBox control to the form's control collection.
    Controls.Add(textBox1);
    // Add the Label control to the form's control collection.
    Controls.Add(label1);
 }

解决方案 »

  1.   

    不是吧,web窗体的控件好像没有location和size属性
      

  2.   

    用你的办法,系统编译错误,提示如下:
    "System.Web.UI.WebControls.Label”并不包含对“Location”的定义
    "System.Web.UI.WebControls.Label”并不包含对“Size”的定义
      

  3.   

    不好意思,搞错了
    我以为是winform
      

  4.   

    private void setstyle(cssStyleCollection style,string left,string top,string width,string height)
    {
    style.Remove("left");
    style.Remove("top");
    style.Remove("width");
    style.Remove("height");
    style.Add("left",left);
    style.Add("top",top);
    style.Add("width",width);
    style.Add("height",height);
    }
    给控件定位:
    setstyle(控件.Style,left,top,width,height);