感谢 vzxq(灵感人) 大侠: 我试过你的方法,可行! foreach (Control c in this.Page.Controls[1].Controls) { if(c is TextBox) ((TextBox)c).Text="qqq"; else if (c is Button) ((Button) c).Enabled=false; } 只是我还不明白为什么要: foreach (Control c in this.Page.Controls[1].Controls) 而不是 foreach (Control c in this.Page.Controls[0].Controls) 或 foreach (Control c in this.Page.Controls) 我开始就是按我上面的两种方法,结果不通! 烦帮我解去迷惑,谢谢!
在page中foreach control 吗?此法我用过,不通啊!
{
if(c is TextBox)
((TextBox)c).Text="";
}
我这个实现 的是把页面上所有TextBox 清空。你试着改一下,
改完了贴出来看看》
Html服务器控件设置Disabled = true;
Web服务器控件Enabled =false;
我试过你的方法,可行!
foreach (Control c in this.Page.Controls[1].Controls)
{
if(c is TextBox)
((TextBox)c).Text="qqq";
else if (c is Button)
((Button) c).Enabled=false;
}
只是我还不明白为什么要:
foreach (Control c in this.Page.Controls[1].Controls)
而不是
foreach (Control c in this.Page.Controls[0].Controls)
或
foreach (Control c in this.Page.Controls)
我开始就是按我上面的两种方法,结果不通!
烦帮我解去迷惑,谢谢!