Differences between Html.TextboxFor and Html.EditorFor in MVC and Razor

前端 未结 5 779
忘了有多久
忘了有多久 2020-11-27 10:24

Why by default were these changed when adding a new \"edit\" view? What are advantages when using EditorFor() vs. TextboxFor()?

I found thi

5条回答
  •  囚心锁ツ
    2020-11-27 10:57

    This is one of the basic differences not mentioned in previous comments:
    Readonly property will work with textbox for and it will not work with EditorFor.

    @Html.TextBoxFor(model => model.DateSoldOn, new { @readonly = "readonly" })
    

    Above code works, where as with following you can't make control to readonly.

    @Html.EditorFor(model => model.DateSoldOn, new { @readonly = "readonly" })
    

提交回复
热议问题