Display Number as Currency
I have a .NET C# app with fields formatted as currency, both in the model and the view.
model
view
It works locally but not on railway, it displays
¤
.
It works if I use [email protected]("#,###,###.##")
in the view but then it will display .2
instead of .20
, and I have to put in the $
character at the beginning.
Any help solving this would be much appreciated.
here is the link to the app
https://mortgagecalculator-asp-net.up.railway.app/Home/AppSolution:Jump to solution
Got it 🙂
in the view
```
@Model.Payment.ToString("C", CultureInfo.CreateSpecificCulture("en-US"))...
14 Replies
Project ID:
N/A
N/A
Looks like your dollar sign isn’t playing nicely with your number format. is it possible to add a $ in the value format like {$0:C0}? I’m thinking like excel
otherwise, take the string from the value format and append on the dollar sign before printing. Don’t run the dollar sign through the value format
no {$0:C0} didn't work.
If I understand you correctly regarding the value format I tried this..
[email protected]("C")
but it displays this $¤
and it still display a .2 without the extra 0displays like that where exactly though?
displays like this on the page
are you sure you are formatting your text with utf-8, that's a common problem I've seen
no not sure. I'm googling it now. Do you know how to do that in a razor view?
nope, never touched .net
definitely something to Google
though, maybe even setting utf-8 on the content headers would be enough, that's actually worked for me before
put this in the razor layout page head tag but it didn't work
I mean on the actual http headers
but it was only a thought
here is the ascii info for this character
Solution
Got it 🙂
in the view
and the using statement at the top of the view
Thanks guys for the help 👍
awesome!