asp.net控件全部清空、全部启用、全部禁用方法
2012-01-31 14:47
459 查看
#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; } }
相关文章推荐
- 禁用asp.net页面中的所有控件 设置本页所有控件的Enabled = false的方法
- asp.net简单实现禁用或启用页面中的某一类型的控件
- asp.net相关控件的客户端及服务器端的禁用和启用
- Asp.net清空控件值的方法(可自定义控件类型)
- 在ASP.NET高级中运用repeater控件来实现禁用与启用。
- 【解决】SharePoint 2010 - ASP.NET 的会话状态已禁用。报表查看器控件要求在本地模式下启用会话状态
- asp.net 简单实现禁用或启用页面中的某一类型的控件
- asp.net 简单实现禁用或启用页面中的某一类型的控件
- asp.net 简单实现禁用或启用页面中的某一类型的控件
- Asp.net_清空控件值的方法(可指定控件类型)
- asp.net相关控件的客户端及服务器端的禁用和启用
- ASP.NET 的会话状态已禁用。报表查看器控件要求在本地模式下启用会话状态。
- asp.net相关控件的客户端及服务器端的禁用和启用
- 关于form表单中禁用所有Asp.net 服务器控件TextBox的方法
- ASP.NET 4 页面控件无法被禁用及产生aspNetDisabled处理方法
- asp.net相关控件的客户端及服务器端的禁用和启用
- Asp.Net页面添加控件方法和原理