更改显示格式数字小数点分隔符 [英] Change display format number decimal separator

查看:26
本文介绍了更改显示格式数字小数点分隔符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下浮点数:-95.83334这是我的视图模型:

I have the following float number : -95.83334 this is in my view model:

[DisplayFormat(DataFormatString = "{0:#.##}")]
public float? mx { get; set; }

这是我的看法

@Html.HiddenFor(model => model.mx)

这是生成的html

<input data-val="true" id="mx" name="mx" type="hidden" value="-95,83334">

这是想要的 html

<input data-val="true" id="mx" name="mx" type="hidden" value="-95.83334">

所以问题是,更改此隐藏输入的小数点分隔符的最佳方法是什么?不改变我项目的其余部分

so the question is, which is the best way to change the decimal separator for this hidden input? without alter the the rest of my project

推荐答案

DisplayFormat 在您使用 Html.DisplayFor 时使用.而且,它仅用于格式化应该在视图上显示的内容.如果您想更改一般十进制数字的格式,则需要使用不同的区域性.

DisplayFormat is used when you use Html.DisplayFor. And, it's only for formatting what's supposed to be displayed on the view. If you want to change the format of decimal numbers in general, you'll need to use a different culture.

这篇关于更改显示格式数字小数点分隔符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆