Html.EditorFor Set Default Value

后端 未结 12 1854
夕颜
夕颜 2020-12-13 03:44

Rookie question. I have a parameter being passed to a create view. I need to set a field name with a default value. @Html.EditorFor(model => model.Id) I need to set this in

12条回答
  •  [愿得一人]
    2020-12-13 03:53

    Its not right to set default value in View. The View should perform display work, not more. This action breaks ideology of MVC pattern. So the right place to set defaults - create method of controller class.

提交回复
热议问题