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.
- 48 to 57 is to allow 0 through 9
- 97 to 122 are a through z (lowercase)
- if you require more ASCII values to be allowed, refer to the chart
<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
2010-08-07 04:41:32
Thanks for help.I work on window application
mahfuz
2010-08-07 04:44:27
sorry..Next i will be more careful ,will you plz help me .How to solve this issue.thanks for reply.
mahfuz
2010-08-07 04:55:56
@mahfuz: I've updated the answer to allow 0-9 and a-z
p.campbell
2010-08-07 05:16:41
+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 >= 48 && e.htmlEvent.keyCode <= 57) ||
(e.htmlEvent.keyCode >= 97 && e.htmlEvent.keyCode <= 122) )
{ }
else { _aspxPreventEvent(e.htmlEvent); }
}"/>
</dx:ASPxTextBox>
DevExpress Team
2010-08-07 17:51:01