日期:2014-05-18  浏览次数:20458 次

想在页面动态加载个TEXTBOX,但是报错!
TextBox TB2 = new TextBox(); 
TB2.Enabled = true; 
TB2.Visible = true; 
this.f.Controls.Add(TB2); 

结果报错类型“TextBox”的控件“_ctl0”必须放在具有 runat=server 的窗体标记内

------解决方案--------------------
必须放在具有 runat=server 的窗体标记内,就是说必须放在FORM里面

this.FindControl("Form1").Controls.Add(TB2);
------解决方案--------------------
this.FindControl("Form1").Controls.Add(TextBox);