views:

163

answers:

2

I work on asp.net C# Window application .in AspxTextbox i want to avoid space and arrow key and also special character .I want just user can input number 0 to 9 and a to z character

A: 

It appears the DevExpress AspxTextbox allows you to specify some JavaScript to achieve this. If you're inclined to use the DexExpress controls to their fullest, consider the ClientSideEvents element. The following JavaScript attached to the KeyPress event will allow numbers only.

<dxe:ASPxTextBox runat="server" EnableClientSideAPI="True" ID="foo"  
                 ClientInstanceName="bar">

  <ClientSideEvents KeyPress="function(s, e) {
  if( 
      (e.htmlEvent.keyCode >= 48 && e.htmlEvent.keyCode <= 57) ||
      (e.htmlEvent.keyCode >= 97 && e.htmlEvent.keyCode <= 122) ) 

  { return true; }
  else {  return false;}

  }" />                                         
</dxe:ASPxTextBox>

Of course, modify as you see fit, and as you require. More context at the DevExpress site.

p.campbell
Thanks for help.I work on window application
mahfuz
sorry..Next i will be more careful ,will you plz help me .How to solve this issue.thanks for reply.
mahfuz
@mahfuz: I've updated the answer to allow 0-9 and a-z
p.campbell
+1  A: 

I would suggest that you use the following code:

      <dx:ASPxTextBox ID="ASPxTextBox1" runat="server" Width="170px">
        <ClientSideEvents KeyPress="function(s, e) { 
if( 
      (e.htmlEvent.keyCode &gt;= 48 &amp;&amp; e.htmlEvent.keyCode &lt;= 57) ||
      (e.htmlEvent.keyCode &gt;= 97 &amp;&amp; e.htmlEvent.keyCode &lt;= 122) ) 

  {  }
  else { _aspxPreventEvent(e.htmlEvent); }
}"/>
        </dx:ASPxTextBox>
DevExpress Team