theclassic
asked on
Asp.Net - Changing number format to display just a value, regardless of negative or positive.
This is a two part question, so I will post the first one...
I have an output where the number is formatted in a currency, and when the value is negative, parenthesis are placed around the asp label that displays the value of the text. Here is the label tag :
<asp:label id="lblIncreaseInAmountCon tributingT o401k" runat="server"/>
__________________________ __________ __________ __________ __________ _________
And here is the code where it is called, computed, and formated, I have broken up the code and listed it in order, as I am not sure how far back it is needed to go to aquire the desired result, but this should be enough :
1)
lblIncreaseInAmountContrib utingTo401 k.text = FormatCurrency(Cdbl(hidden IncreaseIn AmountCont ributingTo 401k.text) )
__________________________ __________ __________ __________ __________ __________
2)
<asp:label id="hiddenIncreaseInAmount Contributi ngTo401k" runat="server"/>
__________________________ __________ __________ __________ __________ __________
3)
hiddenIncreaseInAmountCont ributingTo 401k.text = Cdbl(hiddenFutureContribut ionAmount. text) - Cdbl(hiddenCurrentContribu tionAmount .text)
I am a beginner trying to learn, so thank you for your patience as I learn how to post in the most effective way
I have an output where the number is formatted in a currency, and when the value is negative, parenthesis are placed around the asp label that displays the value of the text. Here is the label tag :
<asp:label id="lblIncreaseInAmountCon
__________________________
And here is the code where it is called, computed, and formated, I have broken up the code and listed it in order, as I am not sure how far back it is needed to go to aquire the desired result, but this should be enough :
1)
lblIncreaseInAmountContrib
__________________________
2)
<asp:label id="hiddenIncreaseInAmount
__________________________
3)
hiddenIncreaseInAmountCont
I am a beginner trying to learn, so thank you for your patience as I learn how to post in the most effective way
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That is giving me an error...I actually wont have access to this page untill tommorrow, so I will check back then. Thank you for your continued help!
ASKER
That is giving me an error...I actually wont have access to this page untill tommorrow, so I will check back then. Thank you for your continued help!
ASKER
Is there a way to just hack it, maybe remove any parenthesis that are in the lable, with jscript? I have tried a number of different formatting techniques, using VbScript, but keep getting an error, as well as with your code...
you could by using string.Replace or Remove, what happens when you just try this
lblIncreaseInAmountContrib utingTo401 k.text = Math.abs(decimal.Parse(hid denIncreas eInAmountC ontributin gTo401k.te xt))
What is the error that you are getting?
lblIncreaseInAmountContrib
What is the error that you are getting?
ASKER
let me try again....one sec
ASKER
The code used is vbscript...isn't this C# ? Thank you for your patients, I am learning as I go....
ASKER
It is working, but I only want two decimal places, and I guess I can just use a dollar sign for the text ?
ASKER
Great, I got it, thank you! I will post my second question seperately.
if this returns a number then
lblIncreaseInAmountContrib