Reputation: 32490
In MVC I have the following attribute on my model.
[DisplayFormat(ApplyFormatInEditMode=true, DataFormatString = "{0:c2}")]
When using DisplayFor this renders as a currency to two decimal places.
However when I use TextBoxFor I get more than two decimal places.
Is there a way to restrict the textbox to two decimal places as well?
Upvotes: 0
Views: 2374
Reputation: 32490
As stated EditorFor will work.
In my case I passed the format string into TextBoxFor
@Html.TextBoxFor(m => m.PaymentAmount, "{0:0.00}"..........)
Upvotes: 0