DisplayFormat(ApplyFormatInEditMode = true,DataFormatString =“ {0:d}”掩盖年份?

时间:2019-06-20 15:59:45

标签: asp.net-mvc

我不想在显示日期时显示年份。我可以使用

DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:d}"

要这样做吗?显示方式如下:

@Html.DisplayNameFor(model => model.Birthday

感谢EB。

@model MVC
.Models.Employee

@{
    ViewBag.Title = "Details";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>Details</h2>

<div>
    <h4>Employee</h4>
    <hr />
    <dl class="dl-horizontal">

        <dt>
            @Html.DisplayNameFor(model => model.Birthday)
        </dt>

        <dd>
            @Html.DisplayFor(model => model.Birthday)
        </dd>
        <dd>
            <img src="/Employees/RetrieveImage/@Model.ID" />
        </dd>
    </dl>
</div>
<p>
    @Html.ActionLink("Edit", "Edit", new { id = Model.ID }) |
    @Html.ActionLink("Delete", "Delete", new { id = Model.ID }) |
    @Html.ActionLink("Back to List", "Employees")

</p>

0 个答案:

没有答案