Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Feb 27, 2010 04:52 PM by Aania
Feb 27, 2010 01:08 PM|LINK
This is a pretty straight-forward question, which I'm sure has a very easy answer that I'm just missing.
I have a textbox with an up/down control, with a minimum of 0 and maximum of 30. Currently, you can also put the cursor into the textbox and type in a value, so I also put in a FilteredTextBoxExtender that will ensure that only numbers can be entered.
It works exactly as advertised, except that it allows the user to enter number less than 0 and more than 30 if they put the cursor into the textbox and type it in.
Is there an easy way to keep the functionality that allows the user to manually edit the box, but ensure that if you type in a number like "200", that it resets it to 30?
I'd rather not have to disable the textbox from user input, but if the above isn't possible, how do I do that and still maintain the up/down functionality? (The samples on the AJAX site work this way, but the setting to disable manual entry must be burried
somewhere in the code, because I did a quick scan and couldn't find it.)
Feb 27, 2010 01:48 PM|LINK
Maybe you can try using a RangeValidator.
Feb 27, 2010 02:24 PM|LINK
Thanks for the suggestion, but if I understand correctly, RangeValidator only works server-side, does it not?
I'm looking for a real-time, clientside solution, similar to how the FilteredTextBoxExtender works client-side.
Feb 27, 2010 02:46 PM|LINK
It works both sides. By default it has EnableClientScript set to true. You might give it a try...
Feb 27, 2010 03:38 PM|LINK
I gave it a try, and it does work client-side, but it still isn't what I'm after unfortunately. :(
This would allow me to post an error message to the user, but instead I just want to automatically reset the textbox value (to 30 if they entered in a value over 30 - entering in a number less than 0 is already impossible since the textbox is already restricted
to numbers only, and the negative symbol isn't a number).
This means, back to the original question. Any easy way to either restrict the user from entering in numbers over 30? (Even if it lets them type in a number like 200, but then as soon as they pull the focus out of the textbox it snaps back to 30.)
Feb 27, 2010 04:00 PM|LINK
be very hard to do, if you are somewhat familiar with JS.
Feb 27, 2010 04:52 PM|LINK
So, on to Plan B. Does anyone know how to disable a Textbox so that it seems enabled (and numericupdownextenders will still work on it), but a user cannot highlight and change the text? The NumericUpDownExtender example given on the AJAX site does this in
a couple of the samples, but I can't find where that option is being turned off/on. URL here: http://www.ajaxcontroltoolkit.com/NumericUpDown/NumericUpDown.aspx
The "June" and "500" examples show the "manual entry disabled" fuctionality I'd like to know how to do.