ASP.NET(C#)中遍历所有控件


for (int i = 0; i < this.Controls.Count; i++) 
{ 
foreach (System.Web.UI.Control control in this.Controls[i].Controls) 
{ 
if (control is TextBox) 
(control as TextBox).Text = ""; 
} 
} 
foreach (Control cl in this.Page.FindControl("Form1").Controls) 
{ 
if (cl.GetType().ToString() == "System.Web.UI.WebControls.TextBox") 
{ 
((TextBox)cl).Text = ""; 
} 
} 

相关阅读 >>

c#中foreach与yield的实例详解

for(;;)什么意思

asp.net(c#)中遍历所有控件

c#中关于foreach遍历使用的深入理解

更多相关阅读请进入《for》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...