private void CleanForm() { foreach (var c in this.Controls) { if (c is TextBox) { ((TextBox)c).Text = String.Empty; }
private void CleanForm(Control ctrl) { foreach (var c in ctrl.Controls) { if (c is TextBox) { ((TextBox)c).Text = String.Empty; } if( c.Controls.Count > 0) { CleanForm(c); } } }
When you initially call ClearForm, pass in this, or Page (I assume that is what 'this' is).