我已使用HiddenInput(DisplayValue = false),例如:
[HiddenInput(DisplayValue = false)]
[DisplayName("Updated By")]
public string Updatedby { get; set; }
但它仍呈现为EditorFor
<div class="form-group">
@Html.LabelFor(model => model.Updatedby, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Updatedby, new { htmlAttributes = new { @class = "form-control" } }) @Html.ValidationMessageFor(model => model.Updatedby, "", new { @class = "text-danger" })
</div>
</div>
我想将其呈现为隐藏字段。我怎样才能做到这一点?谢谢。
您可以使用
@Html.HiddenFor(m=>m.Updatedbynew ,new { @class = "form-control" })
用于在DOM中呈现隐藏的模型绑定字段。