for (int i = 0; i < this.Page.Controls.Count; i++)
{
foreach (System.Web.UI.Control control in this.Page.Controls[i].Controls)
{
if (control is TextBox)
(control as TextBox).Text = "";
if (control is CheckBox)
(control as CheckBox).Checked = false;
if (control is RadioButtonList)
(control as RadioButtonList).SelectedIndex = -1;
}//foreach
}//for
我用这个遍历出来 this.Page.Controls.Count 只有5个(大部分都是HtmlMeta),而我的页面最少也有20多个控件一textbox居多。
可以给个代码吗?具体怎么取出这个div层的控件
追答这个还跟JS 有关了,没那么简单,我现在手头上的电脑刚好是新的,代码不在这儿。555
追问问题我已经解决了!谢谢啊!
foreach (System.Web.UI.Control ctl in this.div3.Controls) {
if (ctl is System.Web.UI.WebControls.TextBox)
{
System.Web.UI.WebControls.TextBox tb = (System.Web.UI.WebControls.TextBox)ctl;
tb.Text = string.Empty;
}
}