HtmlForm form = (HtmlForm) this.FindControl("Form1"); foreach (Control ctrl in form.Controls) { if (ctrl is TextBox) ((TextBox) ctrl).Text = string.Empty; else if (ctrl is DropDownList) ((DropDownList)ctrl).SelectedIndex = 0; }
<script language="javascript" type='text/javascript'> function ClearAllControls() { for (i=0; i<document.forms[0].length; i++) { doc = document.forms[0].elements[i]; switch (doc.type) { case "text" : doc.value = ""; break; case "checkbox" : doc.checked = false; break; case "radio" : doc.checked = false; break; case "select-one" :doc.options[doc.selectedIndex].selected = false; break; case "select-multiple" : while (doc.selectedIndex != -1) { indx = doc.selectedIndex; doc.options[indx].selected = false; } doc.selected = false; break; default : break; } } }</script>
You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$20
For Premium members:
$45
For Elite members: