asp.net控制項全部清空、全部啟用、全部禁用方法

來源:互聯網
上載者:User
 #region//控制項類    public class PubliClass    {        /// <summary>        /// 清空控制項內容        /// </summary>        public static void delContent(Control control)        {            foreach (Control ct in control.Controls)            {                Type tp = ct.GetType();                if (tp.Name == "TextEdit")                {                    ((TextEdit)ct).EditValue = null;                }                else if (tp.Name == "LookUpEdit")                {                    ((LookUpEdit)ct).EditValue = null;                    ((LookUpEdit)ct).ClosePopup();                }                else if (tp.Name == "CheckEdit")                {                    ((CheckEdit)ct).Checked = false;                }                //else if (tp.Name == "TextBox")                //{                //    ((TextBox)ct).Text = null;                //}                else if (tp.Name == "SpinEdit")                {                    ((SpinEdit)ct).Value = decimal.Zero;                }                else if (tp.Name == "MemoEdit")                {                    ((MemoEdit)ct).Text = null;                }                else if (tp.Name == "DateEdit")                {                    ((DateEdit)ct).EditValue = null;                }                else if (tp.Name == "ListBoxControl")                {                    ((ListBoxControl)ct).SelectedItem = null;                }                else if (tp.Name == "RadioGroup")                {                    ((RadioGroup)ct).SelectedIndex = int.MinValue;                }            }        }        /// <summary>        /// 控制項可用        /// </summary>        public static void EditableIS(Control control)        {            foreach (Control ct in control.Controls)            {                Type tp = ct.GetType();                if (tp.Name == "TextEdit")                {                    ((TextEdit)ct).Enabled = true;                }                else if (tp.Name == "LookUpEdit")                {                    ((LookUpEdit)ct).Enabled = true;                }                else if (tp.Name == "CheckEdit")                {                    ((CheckEdit)ct).Enabled = true;                }                //else if (tp.Name == "TextBox")                //{                //    ((TextBox)ct).Enabled = true;                //}                else if (tp.Name == "SimpleButton")                {                    ((SimpleButton)ct).Enabled = true;                }                else if (tp.Name == "ListBoxControl")                {                    ((ListBoxControl)ct).Enabled = true;                }                else if (tp.Name == "DateEdit")                {                    ((DateEdit)ct).Enabled = true;                }                else if (tp.Name == "RadioGroup")                {                    ((RadioGroup)ct).Enabled = true;                }                else if (tp.Name == "MemoEdit")                {                    ((MemoEdit)ct).Enabled = true;                }            }        }        /// <summary>        /// 控制項不可用        /// </summary>        public static void EditableNO(Control control)        {            foreach (Control ct in control.Controls)            {                Type tp = ct.GetType();                if (tp.Name == "TextEdit")                {                    ((TextEdit)ct).Enabled = false;                }                else if (tp.Name == "LookUpEdit")                {                    ((LookUpEdit)ct).Enabled = false;                }                else if (tp.Name == "CheckEdit")                {                    ((CheckEdit)ct).Enabled = false;                }                //else if (tp.Name == "TextBox")                //{                //    ((TextBox)ct).Enabled = false;                //}                else if (tp.Name == "SimpleButton")                {                    ((SimpleButton)ct).Enabled = false;                }                else if (tp.Name == "ListBoxControl")                {                    ((ListBoxControl)ct).Enabled = false;                }                else if (tp.Name == "DateEdit")                {                    ((DateEdit)ct).Enabled = false;                }                else if (tp.Name == "RadioGroup")                {                    ((RadioGroup)ct).Enabled = false;                }                else if (tp.Name == "MemoEdit")                {                    ((MemoEdit)ct).Enabled = false;                }            }        }    }     #endregion
foreach(Control   c   in   this.Controls) {           if(c.Enable==true)           {                 c.Enable=false;           } }

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.