namespace Test
{
public partial class WebForm1 : System.Web.UI.Page
{
static int i = 1;
static List<TextBox> txtList = new List<TextBox>();
protected void Page_Load(object sender, EventArgs e)
{
RestoreTextBox();
}
protected void btnNew_Click(object sender, EventArgs e)
{
TextBox tx = new TextBox();
tx.ID = "txt" + i;
this.PlaceHolder1.Controls.Add(tx);
txtList.Add(tx);
tx.Text = i.ToString();
i++;
}
public void RestoreTextBox()
{
foreach (TextBox tx in txtList)
{
if (tx != null)
{
this.PlaceHolder1.Controls.Add(tx);
}
}
}
}
}