0

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

1 Answer 1

2

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")
Sign up to request clarification or add additional context in comments.

1 Comment

May I request you to please add some more context around your answer. Link-only answers are difficult to understand and are susceptible to become invalid if the website is down or not working. It will help the asker and future readers both if you can reproduce the most relevant portions of the link/blog you are referring to into this post itself.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.