///<summary> /// 清空文本框,如TextBox、<input type="text" />,等等。 /// 主要是对给定的控件进行遍历,如果控件包含子控件,递归,否则判断控件是否为文本框,并作相应的处理,如:给控件属性Text(TextBox)或者value(<input type="text" />)赋上空值。 /// eg:EmptyTextBox(this.form1.Controls); ///</summary> ///<param name="controls"></param> publicvoid EmptyTextBox(ControlCollection controls) { foreach (Control c in controls) { if (c.Controls.Count > 0) { // 递归 EmptyTextBox(c.Controls); } else if (c is TextBox) { // 服务器控件 ((TextBox)c).Text = ""; } else if (c is HtmlInputText) { // HTML 控件 ((HtmlInputText)c).Value = ""; } } }