Reset Text Boxes in ASP.Net
Well a small tip on ASP.NET. Sometimes when creating some user input page we need to clear all the text boxes. One example of this can be a reset or cancel button. Here is a way to do this, iterating through the ASP.Net TextBox controls in a form. Just create a Reset type subroutine - in that routine, use the following code: in C# - it would be: Control myForm = Page.FindControl("Form1"); foreach (Control ctl in myForm.Controls) if(ctl.GetType().ToString().Equals("System.Web.UI.WebControls.TextBox")) ((TextBox)ctl).Text = ""; This will clear EVERYTHING from the textboxes - even if you had them pre-populated with data. Very neat!! Enjoy Programing.. Related Article: Reset Text Boxes in ASP.Net Part 2