Press the Button to create a TextBox control:
The background code is written in the Button_Click event (the background code can also be unloaded in the PageLoad event):
protected void Button1_Click(object sender, EventArgs e)
{int i = 0;
try { i = Int16.Parse(txt_num.Text); }
catch { }
TextBox _txt;
if (i > 0)
{
for (int _i = 0; _i < i; _i++)
{
_txt = new TextBox();
_txt.Text = _i.ToString();
pnl1.Controls.Add(_txt);
}
}
}
Dynamically created controls in PageLoad can retain operational state while static controls cannot