如何在Asp.NETMVC3中设置十进制格式
我需要验证我的编辑器字段以输入产品价格,就像他可以输入整数作为100一样,或者小数点后只允许输入两位数字作为85.12,如果用户输入85,12,它也是有效的,并作为85.12存储在数据库中。 模型类:如何在Asp.NETMVC3中设置十进制格式,asp.net,asp.net-mvc-3,Asp.net,Asp.net Mvc 3,我需要验证我的编辑器字段以输入产品价格,就像他可以输入整数作为100一样,或者小数点后只允许输入两位数字作为85.12,如果用户输入85,12,它也是有效的,并作为85.12存储在数据库中。 模型类: [Required] [LocalizedDisplayName("PRICE_PER_COLLI", NameResourceType = typeof(Strings))] [DisplayFormat(DataFormatString = "{0:n2}", ApplyFormatInEd
[Required]
[LocalizedDisplayName("PRICE_PER_COLLI", NameResourceType = typeof(Strings))] [DisplayFormat(DataFormatString = "{0:n2}", ApplyFormatInEditMode = true)]
public decimal ColliPrice { get; set; }
视图:
model.price)%%>
型号(价格)
我以前做过类似的工作:
@Html.TextBox("ColliPrice", Model.ColliPrice.ToString("0.00"))
@Html.ValidationMessageFor(model => model.ColliPrice)
@Html.TextBox("ColliPrice", Model.ColliPrice.ToString("0.00"))
@Html.ValidationMessageFor(model => model.ColliPrice)