public void Clear(System.Web.UI.Control topctrl)
{
foreach (System.Web.UI.Control ctrl in topctrl.Controls)
{
if (ctrl.GetType().Name== "TextBox")
if (ctrl.ID != "tbEditShijian")
((TextBox)ctrl).Text = "";//清空TextBox
else
((TextBox)ctrl).Text = DateTime.Now.ToString("HH:mm:ss");
else if (ctrl.GetType().Name == "CheckBoxList")//清空CheckBoxList
{
CheckBoxList cbl = ctrl as CheckBoxList;
for (int i = 0; i < cbl.Items.Count; i++)
{
cbl.Items[i].Selected = false;
}
}
else if(...............)
........
if (ctrl.HasControls())
Clear(ctrl);
}
}