wferr

追求完美

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

遍历所有控件

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
="";
    }

}
posted on 2005-12-13 18:03  秋天的虫子  阅读(270)  评论(0)    收藏  举报