0

次のシナリオがあります

public class Foo {
    public Bar FooBar { get; set; }
}

public class Bar {
    [DisplayFormatAttribute(ApplyFormatInEditMode = true, DataFormatString = "{0:d}")]
    public DateTime BirthDay { get; set; }
}

EditorFor を使用するときに、DateTime に DataFormatString を適用したい

@Html.EditorFor(x => x.FooBar.BirthDay);

上記のコードは、DisplayFormatAttribute を使用して日付を正しくレンダリングしません。どうすればこれを解決できますか?

4

1 に答える 1