<asp:Button ID="button1" runat="server" Text="创建" onclick="Button1_Click" /> <asp:Panel ID="Panel1" runat="server"></asp:Panel> //静态变量存储控件列表 static List<TextBox> txtlist = new List<TextBox>(); //控件id static int id = 1; protected void Button1_Click(object sender, EventArgs e) { var txt = new TextBox { ID = id.ToString(), Text = "Sample textbox " + id.ToString() }; this.Panel1.Controls.Add(txt); txtlist.Add(txt); //id自增1 id++; } /// <summary> /// 还原控件 /// </summary> void RestoreTextBox() { foreach (var item in txtlist) { if (item != null) { this.Panel1.Controls.Add(item); } } } /// <summary>