Try it like this:
public class Money { public Money(decimal value) { Value = value; } [DisplayFormat(DataFormatString = "{0:0.00}", ApplyFormatInEditMode = true)] public decimal Value { get; private set; } }
and in your opinion:
<%= Html.EditorFor(x => x.SomePropertyOfTypeMoney.Value) %>
Or you can create your own editor template for Money ( ~/Views/Shared/EditorTemplates/Money.ascx ):
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<AppName.Models.Money>" %> <%= Html.TextBox("", Model.Value.ToString("0.00")) %>
and then, in your opinion:
<%= Html.EditorFor(x => x.SomePropertyOfTypeMoney) %>
source share