【发布时间】:2009-09-26 10:49:14
【问题描述】:
当我动态创建控件并将其添加到页面的控件集合时,我收到以下错误。这是怎么回事?如何动态向页面添加控件?
Control 'ctl02' of type 'TextBox' must be placed inside a form tag with runat=server.
我正在做类似的事情:
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
double total = (double)ViewState[cKeyTotal];
TextBox txt = new TextBox();
txt.Text = "hello world";
this.Controls.Add(txt);
}
【问题讨论】:
标签: asp.net