ASP.NET MVC中,如何设置MVC数据类型货币字段使用数字小键盘触发器?

2026-04-30 16:3213阅读0评论SEO基础
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计305个文字,预计阅读时间需要2分钟。

ASP.NET MVC中,如何设置MVC数据类型货币字段使用数字小键盘触发器?

我的模型包含一个`Datatype.Currency`类型,它是一个十进制对象。我尝试在用户点击时使用视觉图增强,显示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”}?

ASP.NET MVC中,如何设置MVC数据类型货币字段使用数字小键盘触发器?

<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" })

本文共计305个文字,预计阅读时间需要2分钟。

ASP.NET MVC中,如何设置MVC数据类型货币字段使用数字小键盘触发器?

我的模型包含一个`Datatype.Currency`类型,它是一个十进制对象。我尝试在用户点击时使用视觉图增强,显示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”}?

ASP.NET MVC中,如何设置MVC数据类型货币字段使用数字小键盘触发器?

<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" })