这是我在 ASP.NET MVC3 中的 Create.cshtml 的代码片段。我不知道如何将 DateAdded 保存为 DateTimeNow。我使用 CRUDE 创建新记录。我已经尝试删除下面的代码并将其替换为 DateTimeNow(系统时间)而不显示下面代码中的文本框和标签:
<div class="editor-label">
@Html.LabelFor(model => model.DateAdded)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.DateAdded)
@Html.ValidationMessageFor(model => model.DateAdded)
</div>
这是我的 Create.cshtml 片段
@model PhoneBook.Models.Contact
@{
ViewBag.Title = "Create";
}
<h2>Create</h2>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
@using (Html.BeginForm()) {
@Html.ValidationSummary(true)
<fieldset>
<legend>Contact</legend>
<div class="editor-label">
@Html.LabelFor(model => model.DateAdded)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.DateAdded)
@Html.ValidationMessageFor(model => model.DateAdded)
</div>
<p>
<input type="submit" value="Create" />
</p>
</fieldset>
}
<div>
@Html.ActionLink("Back to List", "Index")
</div>