MVC3 EditorFor readOnly

前端 未结 12 1654
谎友^
谎友^ 2020-12-05 09:04

I want to make readOnly with EditorFor in edit page.

I tried to put readonly and disabled as:

@Html.Editor
12条回答
  •  無奈伤痛
    2020-12-05 09:58

    This code is supported in MVC4 onwards

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

提交回复
热议问题