This is a migrated thread and some comments may be shown as answers.

RadNumericTextBox MaxValue Behaviour

8 Answers 470 Views
Input
This is a migrated thread and some comments may be shown as answers.
Adam
Top achievements
Rank 1
Adam asked on 28 Apr 2010, 10:15 AM
Hello chaps,

Quick question:  

I have a RadNumericTextBox with its MinValue property set to 0 and MaxValue property set to 1000.  I've worked out that I can use the ClientEvents-OnError property to call a JavaScript function and display an alert box when the user enters a value outside of the range, but is it possible to also clear the RadNumericTextBox raising the error, rather than have it revert to 1000 if the value entered is bigger and 0 if the value is smaller?

Cheers,

Adam


8 Answers, 1 is accepted

Sort by
0
Adam
Top achievements
Rank 1
answered on 28 Apr 2010, 03:03 PM
Come on, fellas!  Help a brother out! :-)
0
robertw102
Top achievements
Rank 1
answered on 28 Apr 2010, 03:33 PM
Have you tried doing this:

function HandleError(sender, eventArgs) 
 { 
   sender.clear(); 
 } 

You can call the RadNumericTextboxes clear method.

I hope that helps.
0
Adam
Top achievements
Rank 1
answered on 28 Apr 2010, 03:40 PM
I'm afraid that hasn't sorted it.  The value still flicks back to either the max or min value.  It feels like the reset to min/max happens after the OnError event...
0
robertw102
Top achievements
Rank 1
answered on 28 Apr 2010, 04:10 PM
Perhaps you cancel the event by calling args.set_cancel(true) and then clearing it.
0
Martin
Telerik team
answered on 28 Apr 2010, 04:19 PM
Hello Guys,

Another approach you can try is to apply a slight delay to the "clearing" operation:

function Error(sender, args)
{
    alert("Invalid!");
    setTimeout(function()
    {
        sender.clear();
    }, 10);
 
}


I hope this helps,
Martin
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Adam
Top achievements
Rank 1
answered on 28 Apr 2010, 04:35 PM
Hi, 

Thanks for your help...

The cancelling and then clearing doesn't clear my textbox (it doesn't appear to do anything), and Martin's sample code makes alert box pop-ups keep happening, indefinitely.

I'm working on a project which has a fairly old version of Telerik (2008.2.1001.20) if that gives any clues, but unfortunately I'm not in a position to install a newer version.

EDIT:  Just had a thought: does .clear() reset the text box to 0?  Because on some of my textboxes the minimum value is 100.

Cheers,

Adam
0
Adam
Top achievements
Rank 1
answered on 30 Apr 2010, 10:28 AM
Just a quick follow up:

Martin's solution should work if your MinValue = 0.  If your MinValue is larger than 0 (as mine was) then an infinite loop is created as .clear() fires the OnError event again - perhaps internally .clear() sets to a value to zero, I dunno.

Anyway, the way I got round this was to extend the RadNumericTextBox class and add two properties of my own: customMin and customMax.  Setting these properties now writes two HiddenFields to the page and those hidden fields can be accessed via JS to check the value entered is within the range.  Not setting the built-in MinValue and MaxValue properties gets around the value being reverted to MinValue/MaxValue if you go over or under.

I'd like to suggest a property that allows you to specify how values are handled by RadNumericTextBox if they're outside of your specified range.  Perhaps: clear textbox | preserve user's entered number | revert to min/max value.

Cheers,

Adam
0
Martin
Telerik team
answered on 30 Apr 2010, 04:07 PM
Hello Adam,

Indeed you are correct that when MinValue different than 0 is set, the described erroneous behavior is observed in the 2008.2.1001 version of the RadNumericTextBox. However note that this issue is already fixed in the latest version of RadControls for ASP .NET AJAX.

Regards,
Martin
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Input
Asked by
Adam
Top achievements
Rank 1
Answers by
Adam
Top achievements
Rank 1
robertw102
Top achievements
Rank 1
Martin
Telerik team
Share this question
or