private void DisableChildControl(Control c)
    {
        if (c is TextBox)
        {
            (c as TextBox).Enabled = false;
        }
        if (c is DropDownList)
        {
            (c as DropDownList).Enabled = false;
        }
        if (c is DateTimeControl)
        {
            (c as DateTimeControl).Enabled = false;
        }
        if (c.HasControls())
        {
            foreach (Control ctl in c.Controls)
            {
                DisableChildControl(ctl);
            }
        }
    }
    private void DisableTextBoxs()
    {
        try
        {
            foreach (Control cp in Page.Controls)
            {
                DisableChildControl(cp);
            }
        }
        catch (Exception ex)
        {
            string sMessage = ex.Message;
        }

    }

 

遍历控件

 

posted on 2012-05-10 13:23  gzh4455  阅读(229)  评论(0编辑  收藏  举报