Clear all fields in ASP.net form -


Is there an easy way to reset all the fields in a form?

I have around 100 controls in my ASP.NET form and there are submitted and reset buttons.

How can I tap all the values ​​when the user reset the reset button?

I have a lot of dropdown boxes, text boxes, check boxes

on page Loop through all the controls, and if the control type is a text box, then set the text property for the string. Empty

  Protected Zero Textbox (Control Page 1) {foreach (control Ctrl in Controls Ctrl) {if (ctrl is text box) {Text box T = as text box; If (t! = Null) {t. Text = string Empty; }} And {if (ctrl.Controls.Count> 0) {ClearTextBoxes (ctrl); }}}}  

Then call it in your click event like this:

  ClearTextBoxes (page);  

Comments