遍历页面的控件
foreach(Control ctl in this.Page.Controls[1].Controls)
{
if(ctl.GetType() == typeof(TextBox))
{
TextBox t = (TextBox) ctl;
t.Text = string.Empty;
}
}
递归便利子容器控件的控件
例如:
private void SetTextEmpty(Control c)
{
foreach(Control childControl in c.Controls)
{
if(childControl is TextBox)
((TextBox)c).Text="";
else
SetTextEmpty(childControl);
}
}
然后就直接SetTextEmpty(Page);就好了
{
if(ctl.GetType() == typeof(TextBox))
{
TextBox t = (TextBox) ctl;
t.Text = string.Empty;
}
}
递归便利子容器控件的控件
例如:
private void SetTextEmpty(Control c)
{
foreach(Control childControl in c.Controls)
{
if(childControl is TextBox)
((TextBox)c).Text="";
else
SetTextEmpty(childControl);
}
}
然后就直接SetTextEmpty(Page);就好了
posted on 2006-12-27 13:16 hnsjack(痞子龍) 阅读(115) 评论(0) 编辑 收藏 举报