MVC3 EditorFor readOnly

前端 未结 12 1655
谎友^
谎友^ 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:46

    I know the question states MVC 3, but it was 2012, so just in case:

    As of MVC 5.1 you can now pass HTML attributes to EditorFor like so:

    @Html.EditorFor(x => x.Name, new { htmlAttributes = new { @readonly = "", disabled = "" } })
    

提交回复
热议问题