textbox 控键问题
有没有属性能控制textbox 只能输入数字

解决方案 »

  1.   

    用控件的 attributes.add("onKeyPress","if(event.keyCode<48||event.keyCode>57)event.returnValue=null;")
      

  2.   

    textbox.Attributes.add("onKeyPress","value=value.replace(/[^\d]/g,'')")
      

  3.   

    textbox.Attributes.Add("onKeyPress","value=value.replace(/[^\d]/g,'')")
      

  4.   

    请问楼上的  
       VS2005里面怎么实现? 
         
       2005的TextBox好像没有Attributs.Add()的方法
      

  5.   

    在Keydown或者是KeyPress中有一个属性是Handled?
    在keyPress中加入:
    if( (e.KeyChar < '0' || e.KeyChar > '9') && e.KeyChar != (char)Keys.Back )
    e.Handled = true; 就可以只输入数字了,
    Keydown中好像没有KeyChar ,但是有KeyCode