Html.EditorFor additionalViewData

后端 未结 2 1768
遥遥无期
遥遥无期 2020-12-30 18:46

I have a custom editor template where I add values to the ViewData like so:

@Html.EditorFor( model => model.PhoneNumber , new { Title = \"Som         


        
2条回答
  •  被撕碎了的回忆
    2020-12-30 18:52

    You can nest your htmlAttributes object in view data:

    <%= Html.EditorFor(model => model.PhoneNumber, new { htmlAttributes = new { Title = "SomeValue" } })
    

    Then in your editor template:

    <%= Html.TextBox("", Model.Value, ViewData["htmlAttributes"])%>
    

提交回复
热议问题