如何重写TextBox的Text属性,需要详细的完整的示例``SOS

解决方案 »

  1.   

    我只要是想过滤一些字符 所以重些Text的属性 在里面加一个我自己的过滤的方法
      

  2.   

    public class MyTextBox : System.Web.UI.WebControls.TextBox
    {
        public override string Text 
        {
            get { return base.Text; }
            set 
            {
                // 验证代码
                // ...
                // example validation case
                if(value != "csdn") thrown new Exception("请输入小写的csdn");
                // ...
                base.Text = value;
            }      
    }
      

  3.   

    public class usertxtbox : System.Windows.Forms.TextBox
    {
    public override string Text
    {
    get
    {
    return base.Text;
    }
    set
    {
    base.Text = value;
    }
    } }