RadNumericTextBox MaxValue Behaviour

9 posts, 0 answers
  1. Adam
    Adam avatar
    13 posts
    Member since:
    Apr 2008

    Posted 28 Apr 2010 Link to this post

    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


  2. Adam
    Adam avatar
    13 posts
    Member since:
    Apr 2008

    Posted 28 Apr 2010 Link to this post

    Come on, fellas!  Help a brother out! :-)
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. robertw102
    robertw102 avatar
    265 posts
    Member since:
    Jul 2007

    Posted 28 Apr 2010 Link to this post

    Have you tried doing this:

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

    You can call the RadNumericTextboxes clear method.

    I hope that helps.
  5. Adam
    Adam avatar
    13 posts
    Member since:
    Apr 2008

    Posted 28 Apr 2010 Link to this post

    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...
  6. robertw102
    robertw102 avatar
    265 posts
    Member since:
    Jul 2007

    Posted 28 Apr 2010 Link to this post

    Perhaps you cancel the event by calling args.set_cancel(true) and then clearing it.
  7. Martin
    Admin
    Martin avatar
    811 posts

    Posted 28 Apr 2010 Link to this post

    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.
  8. Adam
    Adam avatar
    13 posts
    Member since:
    Apr 2008

    Posted 28 Apr 2010 Link to this post

    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
  9. Adam
    Adam avatar
    13 posts
    Member since:
    Apr 2008

    Posted 30 Apr 2010 Link to this post

    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
  10. Martin
    Admin
    Martin avatar
    811 posts

    Posted 30 Apr 2010 Link to this post

    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017