一个类控制不同种类控件的同时启用或停用

本文介绍了一个实用的工具类,用于批量设置ASP.NET页面上各类控件的启用状态及只读属性,包括按钮、文本框、复选框等,并提供了详细的实现方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

      先声明下,这个类是老外写的,非原创,但挺有用的。分享一下

1,枚举

 1using System;
 2
 3namespace Clingingboy
 4{
 5    /// <summary>
 6    /// 启用控件枚举
 7    /// </summary>

 8    public enum ControlName
 9    {
10        /// <summary>
11        /// Includes asp.net button, image button, link button, html button.
12        /// </summary>

13        Button,
14        /// <summary>
15        /// Includes asp.net text box, html input text, html text area server controls.
16        /// </summary>

17        TextBox,
18        /// <summary>
19        /// Includes asp.net check box and html input check box.
20        /// </summary>

21        CheckBox,
22        /// <summary>
23        ///    Includes asp.net drop down list, list box, html select.
24        /// </summary>

25        ListControl,
26        /// <summary>
27        /// Includes asp.net validators.
28        /// </summary>

29        Validator,
30        /// <summary>
31        /// All the controls that are defined in this enum.
32        /// </summary>

33        All
34    }

35}

36

2,最后一个方法无效,因为Control不存在此属性
  1using System;
  2using System.Text;
  3using System.Web;
  4using System.Web.UI;
  5using System.IO;
  6using System.Net;
  7using System.Text.RegularExpressions;
  8using System.Web.UI.WebControls;
  9using System.Web.UI.HtmlControls;
 10
 11
 12namespace Clingingboy
 13{
 14    /// <summary>
 15    /// 控件启用状态
 16    /// </summary>

 17    public class ControlEnabler
 18    {
 19
 20        Page Control Enabling / Disabling Utility
167    }

168}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值