ASP.NET MVC4 を使用して、ユーザーが Author、Text、および CreateTime を指定する CreateView を作成しました。ユーザーに CreateTime を表示したり入力したりしたくありません。自分のコードでDateTime.Now.ToShortDateTime()
.
それは私のCreateViewのこの部分です。
@Html.EditorFor(model => model.CreateTime)
編集: ここに私の CreateView があります:
@model Models.Topic
@using (Html.BeginForm()) {
@Html.ValidationSummary(true)
<fieldset>
<legend>Topic</legend>
<div class="editor-label">
@Html.LabelFor(model => model.Name)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Name)
@Html.ValidationMessageFor(model => model.Name)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Author)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Author)
@Html.ValidationMessageFor(model => model.Author)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.CreateTime)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.CreateTime)
@Html.ValidationMessageFor(model => model.CreateTime)
</div>
<p>
<input type="submit" value="Create" />
</p>
</fieldset>
}
<div>
@Html.ActionLink("Back to List", "Index")
</div>
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}