Soheil Alizadeh
Soheil Alizadeh

Reputation: 3066

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 :

   [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.

at the end

I Have following format

22,222,222 // this is currency

Upvotes: 0

Views: 1407

Answers (1)

Giorgi Dolmazashvili
Giorgi Dolmazashvili

Reputation: 36

For formatting textbox value you can use jquery masked input plugin: http://digitalbush.com/projects/masked-input-plugin/

At first you should include jquery plugin: https://jquery.com/

Than you can use following code:

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

Upvotes: 2

Related Questions