void clean()//循环清空
{
for (int i = 0; i < Page.Controls.Count; i++)
{
foreach (System.Web.UI.Control control in Page.Controls[i].Controls)
{
if (control is TextBox)
{
(control as TextBox).Text = "";
}
}
}
}
JS版
<script language="javascript" type="text/javascript">
function ClearAll()
{
var temp=document.forms[0].elements;
for(var i=0;i<temp.length;i++)
{
if(temp[i].type=="text"||temp[i].type=="textarea")
{
temp[i].value="";
}
}
}
</script>
<input name="button" type="button" onclick="ClearAll()" value="清空" />
最直接的方法
<input type="reset" name="Submit" value="重置" />