Try this:
make a method like this:
private void ClearFormControlValues(Control parent)
{
foreach (Control c in parent.Controls)
{
if (c.Controls.Count > 0)
{
ResetFormControlValues(c);
}
else
{
switch (c.GetType().ToString())
{
case "System.Web.UI.WebControls.TextBox":
((TextBox)c).Text = "";
break;
case "System.Web.UI.WebControls.CheckBox":
((CheckBox)c).Checked = false;
break;
case "System.Web.UI.WebControls.RadioButton":
((RadioButton)c).Checked = false;
break;
}
}
}
}
And call this method on button click or any other event you want like this:
protected void submit_Click(object sender, EventArgs e)
{
ClearFormControlValues(this);
}
this will clear all the textboxes, checkboxes & radio buttons on your form, you can remove checkbox and radiobutton if you want only textboxes to clear, in the same way you can add more control.
hope it helps :)