Asp.net-Mvc

HtmlHelper NameFor 方法

  • July 19, 2018

是否有一個Html.NameFor功能可以獲取name模型項的 html 屬性?

我想在我的 Razor 視圖中使用以下程式碼:

<input type="text" value="@Model.User.Email" name="@Html.NameFor(x => x.User.Email)">

是的,ASP.NET MVC Futures 程序集中有Html.NameFor方法。

Html.NameFor現在包含在 MVC 4 中。

引用自:https://stackoverflow.com/questions/3444021