一个aspx页面里所有的控件

for (int j = 0; j < this.Controls.Count; j++)       
          { 
foreach (object o in Page.Controls[j].Controls)  
{    
if (o is  DropDownList)  
{  
  DropDownList drop = (System.Web.UI.WebControls.DropDownList)o;   
if (drop.ID.Contains("C"))
{
BindCoro(drop);
}  

}   

 

void Emptcontro(Control cc)//清空页面所有的textbox文本
{
if (cc == null)
{
for (int j = 0; j < this.Controls.Count; j++)
{
foreach (Control o in Page.Controls[j].Controls)
{
Emptcontro(o);
if (o is TextBox)
{
TextBox txt = (System.Web.UI.WebControls.TextBox)o;
txt.Text = string.Empty;
}
}
}
}
else {
if (cc is TextBox)
{
TextBox txt = (System.Web.UI.WebControls.TextBox)cc;
txt.Text = string.Empty;
}
else
{
foreach (Control o in cc.Controls)
{
Emptcontro(o);
}
}
}
}

posted @ 2012-08-27 14:15  文艺流浪汉  阅读(190)  评论(0编辑  收藏  举报