I have an ASP.NET MVC app. My app has a Razor view that generates some JavaScript. That block of code looks like this:
<script type="text/javascript">
@if (Model == null)
{
var amount = 0;
}
else
{
<text>var amount = @Convert.ToString(Model.DailyAmount.Value);</text>
}
...
</script>
When a user's culture is set to Germany ("de-DE"), the view gets rendered as: var amount = 0,00;
DailyAmount
is a decimal?
Notice how the value that gets rendered ( 0,00
) has a comma to represent a decimal. However, I want to always render the value as 0.00 instead. How do I do this?
Thank you!
为您的金额指定确切的文化-即:
@Convert.ToString(Model.DailyAmount.Value, CultureInfo.InvariantCulture)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.