如何将ASP.NET MVC中的货币类型数字小键盘改写成长尾词?
- 内容介绍
- 文章标签
- 相关推荐
本文共计302个文字,预计阅读时间需要2分钟。
我的模型包含一个Datatype(货币类型),它是一个十进制对象。我尝试在用户点击时触发iPad/iPhone上的数字键盘。当对象是INT类型而不适用于Decimal时,它仍然可以工作。以下是模型的片段。
我的模型有一个Dataype(Datatype.Currency),它是一个十进制对象.我试图强制视图在用户点击它时触发ipad / iphone上的数字小键盘.当对象是INT但不适用于Decimal时,它可以工作.
下面是模型的片段(我尝试使用正则表达式无效):
[Display(Name = "Bid Price")] [DataType(DataType.Currency)] //[RegularExpression("([1-9][0-9]*)")] public decimal BidPrice { get; set; }
这是视图的片段.有没有办法以某种方式使用新的{@inputtype =“number”}?
<div class="col-md-10"> @Html.EditorFor(model => model.BidPrice, new { @type= "number" }) @Html.ValidationMessageFor(model => model.BidPrice) </div>
如果你有这个工作,请帮忙.
除非您使用MVC-5.1或更高版本,否则EditorFor()方法不支持添加htmlAttributes.如果你是语法是@Html.EditorFor(m => m.BidPrice, new { htmlAttributes = new { @type= "number" } })
如果不是,则需要使用TextBoxFor()方法添加属性
@Html.TextBoxFor(m => m.BidPrice, new { @type= "number" })
本文共计302个文字,预计阅读时间需要2分钟。
我的模型包含一个Datatype(货币类型),它是一个十进制对象。我尝试在用户点击时触发iPad/iPhone上的数字键盘。当对象是INT类型而不适用于Decimal时,它仍然可以工作。以下是模型的片段。
我的模型有一个Dataype(Datatype.Currency),它是一个十进制对象.我试图强制视图在用户点击它时触发ipad / iphone上的数字小键盘.当对象是INT但不适用于Decimal时,它可以工作.
下面是模型的片段(我尝试使用正则表达式无效):
[Display(Name = "Bid Price")] [DataType(DataType.Currency)] //[RegularExpression("([1-9][0-9]*)")] public decimal BidPrice { get; set; }
这是视图的片段.有没有办法以某种方式使用新的{@inputtype =“number”}?
<div class="col-md-10"> @Html.EditorFor(model => model.BidPrice, new { @type= "number" }) @Html.ValidationMessageFor(model => model.BidPrice) </div>
如果你有这个工作,请帮忙.
除非您使用MVC-5.1或更高版本,否则EditorFor()方法不支持添加htmlAttributes.如果你是语法是@Html.EditorFor(m => m.BidPrice, new { htmlAttributes = new { @type= "number" } })
如果不是,则需要使用TextBoxFor()方法添加属性
@Html.TextBoxFor(m => m.BidPrice, new { @type= "number" })

