清空所有textbox

 public void EmptyTextBox(ControlCollection controls)
    {
        foreach (Control c in controls)
        {
            if (c.Controls.Count > 0)
            {
                // 递归                
                this.EmptyTextBox(c.Controls);
            }
            else if (c is TextBox)             {
                // 服务器控件                
                ((TextBox)c).Text = "";
            }
            else if (c is HtmlInputText)
            {
                // HTML 控件                
                ((HtmlInputText)c).Value = "";
            }
        }
    }

 

posted on 2013-05-30 14:11  小景  阅读(303)  评论(0编辑  收藏  举报