HiddenInput在视图MVC 5上渲染时不起作用

问题描述 投票:0回答:1

我已使用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>

我想将其呈现为隐藏字段。我怎样才能做到这一点?谢谢。

asp.net-mvc asp.net-mvc-5
1个回答
0
投票

您可以使用

@Html.HiddenFor(m=>m.Updatedbynew ,new { @class = "form-control" })

用于在DOM中呈现隐藏的模型绑定字段。

© www.soinside.com 2019 - 2024. All rights reserved.