今天看了篇博友的文章,讲到了清空页面所有的值,看了一下,还可以!不过可以更简单些!
解决方案如下:
后台的方法:(具体什么事件触发它,大家自己做主)
这里以button清空按钮 触发
cs: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); } } 到这里大家应该明白了!自己试下吧!有问题可以给我留言交流下!
清空页面所有值的
TAG: