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

Percentage Textbox

7 Answers 479 Views
Input
This is a migrated thread and some comments may be shown as answers.
Scott Rakestraw
Top achievements
Rank 1
Scott Rakestraw asked on 15 Jan 2008, 04:35 PM
I like the features of the numeric textbox but was wondering if I could implement it so that a user entered a decimal and it was shown as a percentage (ie enter 0.01 and see 1%).  I'm hoping to not have to use the masked textbox since it seems there that you are predefining the size of the text.

7 Answers, 1 is accepted

Sort by
0
plamen
Top achievements
Rank 1
answered on 16 Jan 2008, 09:23 AM
hi :)

RadNumericTextBox exposes simple yet powerful API so that you may manipulate its value using custom client side code.

More about the client side API of the control you can learn from the Client-side API reference section in the grid documentation:

http://www.telerik.com/help/radcontrols/prometheus/


The following code example demonstrates how to achieve your goal:

    <div>
        <script type="text/javascript">
        function Blur(sender, args)
        {
            var input = sender;
            input.setValue(input.getValue() * 100);
        }
        </script>   
        <rad:RadNumericTextBox Type="Percent" ID="RadNumericTextBox1" runat="server">
            <ClientEvents OnBlur="Blur" />
        </rad:RadNumericTextBox>
    </div>

Thanks...
<John:Peel />



0
Ray
Top achievements
Rank 1
answered on 18 Apr 2009, 04:17 AM
The point here is that the MS framework default is 0->1 not 1 to 100 this like other problems occur becuase the controls dont "fit"
if you dont wantt o change then simply have an option to align with MSoft framework, i.e o->1 display 1->100, having to hack java code to make this work is a waste of time..


0
ManniAT
Top achievements
Rank 2
answered on 24 Apr 2009, 09:43 PM
Hi Ray,

I'm not sure what you are talking about - is there any MS Percentage Input Control?
I mix MS controls (not the ajax toolkit - I gave up after some weeks working around problems) and telerik controls just as it fit's my needs. Stupid text input - why shall I use telerik - enhanced things I just use one of the RadControls.

And the great thing (as this sample proofs) - just a few lines of javascript or code behind and the things do what you want.

To point this out - take a MS Textbox and "teach it" to accept decimal values which will later be displayed as values from 0 to 100.
Is this possible without code (java or whatever)?

But writing a single function with ONE line of code (no need for var... .sender.setValue(sender.getValue() * 100); would do the job also) is from my point of view the opposite of waste of time.
It is customizable functionality out of the box.

And also an interesting thing about this telerik controls - did you recognize that Scott had a problem - and got it solved by John within one day?
As every other framework the telerik controls need some time to learn and understand them. BUT - most of the things work in the MS-way (I did a lot of migration just by changing the tag of the asp:xxxx control to telerik:yyyy), and there is a excellent support - I was NEVER left alone with a problem. Either a telerik employee solved it for me - or another customer was even faster than the support guys.

Again - I don't us the MS controls so much (except for straight simple things) - so I may have overseen some control that is capable of doing what Scott needs.

Can you please clarify your post and point me to that MSFramework you are talking about?

Kind Regards

Manfred
By the way - I (and so my customers) are jused to put in percentages as integers - so the control works for me without modifications.
But this may be an Austrian problem :)
0
Ray
Top achievements
Rank 1
answered on 24 Apr 2009, 11:06 PM
ManniAT 

Posted 1 hour ago

Hi Ray,

"I'm not sure what you are talking about - is there any MS Percentage Input Control?"
>> No, I refered to the framework, not a control.. see any of the percentage formating funtions etc which one would use as part of say a binding operation.. These all are based around a 0->1 range..

And the great thing (as this sample proofs) - just a few lines of javascript or code behind and the things do what you want.
>> Have used (pre ajax) percentage controls for many years, dont need any additional "java" script just use ot of the box, not that difficult.. why go backwards..


It is customizable functionality out of the box.
>> No... basic funtionality is in the control, customisation is for extendign basic funtionality, percentage controls should do just that..
I have no problem with extension for doing sometuing outside of the basic funtionality..

Can you please clarify your post and point me to that MSFramework you are talking about?
>> AA

Kind Regards

Manfred
By the way - I (and so my customers) are jused to put in percentages as integers - so the control works for me without modifications.
>> Missed the point... a basic percentage control displays 1-100 (human natual viewpoint) and interfaces with the framework ( its internal specification) in the required 0-1 range..
Very basic stuff, and common in pre ajax controls..

No need to re-invent the wheel here, just best practice..

0
ManniAT
Top achievements
Rank 2
answered on 25 Apr 2009, 11:26 AM
Hi Ray,

thanks for the explanation.
What I told in my last sentence was really true - I user 30 to enter 30% 75 to enter 75% and so on.

Maybe this is the reason that I never found Framework (.NET, LINQ, DataBinder..) functions for percentage that take decimals and display integer (or such a thing).
Just because I'm curios - could you please point me to one of that framework functions you talk about?
And so I want to excuse me for my first post - I just wrote it because in this point I have a lack of knowledge (I'm really not aware of percentage functionality in the framework) - and so I misunderstood what you wrote about "framework" - I thought you talked about some features MS controls may provide.

Anyhow you wrote:
>> Have used (pre ajax) percentage controls for many years, don't need any additional "java" script just use out of the box, not that difficult.. why go backwards..

This leads the discussion to a different point - there are (and I'm sure you are right) such controls out there.
But I've never seen such a thing at telerik in the last five years (could have been there - you know I use 30, 75...:)).

So (if I haven't overseen it) telerik never had such a thing - which turns "move backward" to a "feature wish".

Regards

Manfred
0
Ray
Top achievements
Rank 1
answered on 25 Apr 2009, 08:47 PM
What I told in my last sentence was really true - I user 30 to enter 30% 75 to enter 75% and so on.
>> Not sure the point, what else would one use for a GUI..

Just because I'm curios - could you please point me to one of that framework functions you talk about?

>> format expressions like {0:P2}

So (if I haven't overseen it) telerik never had such a thing - which turns "move backward" to a "feature wish".
>> No, simple dont re-invent the wheel, controls need to be complient with the framework upon which they exist..
The current percentage control is a backward step for anyone who has used existing controls and wants to use RAD to upgrade to ajax versions..

Having said this I am hoping that the Q2 release will have fixed all the basic gotchas like this and other basic stuff like the inability to pop up a calander at the bottom of a page.. These things break what otherwise would be a great replacement for existing non ajax controls..





0
ManniAT
Top achievements
Rank 2
answered on 25 Apr 2009, 10:05 PM
I use these controls since 5 years now.
And there has always been the one or the other things missing.

BUT (and that's just one of the points why I love to use these controls) - if a certain number of customers had a need - it did never take long to have the thing included in the controls.
And that by keeping the controls (as good as possible) compatible. So upgrades have never been a big amount of work.

I guess if this feature is something needed telerik will do it.

Meanwhile there is a way - like John showed it - so no one get's stopped in his / her project.

Regards

Manfred
PS: thanks for the format string I've relay not be aware of it (since I write 30 / 75 you remember :) I didn't even miss it)
BUT - I can understand now what you meant
Tags
Input
Asked by
Scott Rakestraw
Top achievements
Rank 1
Answers by
plamen
Top achievements
Rank 1
Ray
Top achievements
Rank 1
ManniAT
Top achievements
Rank 2
Share this question
or