Html.EditorFor Set Default Value

后端 未结 12 1872
夕颜
夕颜 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:46

    This worked for me

    In Controlle

     ViewBag.AAA = default_Value ;
    

    In View

    @Html.EditorFor(model => model.AAA, new { htmlAttributes = new { @Value = ViewBag.AAA } }
    

提交回复
热议问题