RadNumericTextBox - set number format in javascript

3 posts, 1 answers
  1. Antonio
    Antonio avatar
    10 posts
    Member since:
    Oct 2011

    Posted 20 Aug 2012 Link to this post

    Hello,

    I have a RadNumericTextBox and I want to toggle between Number and Percent number format type when I check or uncheck a checkbox. It is possible to do that in JavaScript? I saw RadNumericTextBox has set_numberFormat function, but i don't know how to handle it.

    Thanks!
  2. Answer
    Eyup
    Admin
    Eyup avatar
    3012 posts

    Posted 22 Aug 2012 Link to this post

    Hello Antonio,

    I have attached a sample web site where I implemented the requested functionality. Please check out the attached application and let me know about the result.

    Greetings,
    Eyup
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Antonio
    Antonio avatar
    10 posts
    Member since:
    Oct 2011

    Posted 22 Aug 2012 Link to this post

    Hi Eyup,

    It worked! I changed a bit your code, and my function is:

    function checkFunction(){
                var numBox = $find("<%#...my control%>");
                var value = numBox.get_value();
                numBox.get_numberFormat().PositivePattern = "n" + (chk.checked ? " %" : "");
                numBox.get_numberFormat().NegativePattern = "-n" + (chk.checked ? " %" : "");
                numBox.clear();
                numBox.set_value(value);
    }

    with call from code-behind:
                my control.Attributes["onclick"] = "checkFunction(this);";
    where [my_control] is RadNumericTextBox control

    Thanks a lot!
Back to Top