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

RadNumericTextBox - set number format in javascript

2 Answers 93 Views
Input
This is a migrated thread and some comments may be shown as answers.
Antonio
Top achievements
Rank 1
Antonio asked on 20 Aug 2012, 11:35 AM
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 Answers, 1 is accepted

Sort by
0
Accepted
Eyup
Telerik team
answered on 22 Aug 2012, 12:57 PM
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.
0
Antonio
Top achievements
Rank 1
answered on 22 Aug 2012, 03:48 PM
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!
Tags
Input
Asked by
Antonio
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Antonio
Top achievements
Rank 1
Share this question
or