简体   繁体   English

ASP.NET MVC中的自定义输入格式

[英]Custom Input Format In ASP.NET MVC

I have a view named CreateProject.cshtml that it strongly type of CreateProjectViewModel when i want do use custom format for One of inputs that for this use Following Code in CreateProjectViewModel : 我有一个名为观点CreateProject.cshtml它强类型的CreateProjectViewModel当我要为一体的投入做使用自定义格式,为了这个,使用下面的代码CreateProjectViewModel

   [DisplayFormat(DataFormatString = "{0:###,###.####}", ApplyFormatInEditMode = true)]
   public decimal Price { get; set; }

Well I try this way but worked also use Following Code : 好吧,我尝试这种方式,但也使用了以下代码:

@Html.TextBoxFor(m => m.ProjectPrice, new { @Value = Model.ProjectPrice.ToString("0:###,###.####") })

Still does not work, For solve this problem i see other questions. 仍然不起作用,为解决此问题,我看到了其他问题。

Also I should add that I Use Automapper for mapping ViewModels and tried create custom format with formatter.js but still does not work. 另外,我还应该补充一点,我使用Automapper映射ViewModels,并尝试使用formatter.js创建自定义格式,但仍然无法正常工作。

at the end 在末尾

I Have following format 我有以下格式

22,222,222 // this is currency

For formatting textbox value you can use jquery masked input plugin: http://digitalbush.com/projects/masked-input-plugin/ 要格式化文本框值,您可以使用jquery屏蔽的输入插件: http : //digitalbush.com/projects/masked-input-plugin/

At first you should include jquery plugin: https://jquery.com/ 首先,您应该包括jquery插件: https : //jquery.com/

Than you can use following code: 比您可以使用以下代码:

$("#ProjectPrice").mask("99,999,999")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM