@Html.EditorFor怎么设置属性为只读属性

2025-04-28 16:39:52
推荐回答(2个)
回答1:

@Html.EditorFor(model => model.Name, new { disabled = "disabled " })
@Html.EditorFor(model => model.Name, new { disabled = "" })
就可以了。

回答2:

@Html.EditorFor(model => model.Num, new { htmlAttributes = new { @class = "form-control", @readonly = "readonly" } })