Tag: mvc editor templates

如何在一个foreach中使用EditorFor

我有一个模型: public class MyListModel { public int ID {get;set;} public List<User> Users{get;set;} } 如何在foreach中使用Html.EditorFor方法? @model MyListModel <table> <tr> <th></th> </tr> @foreach (var item in Model.Users) { <tr> <td> @Html.EditorFor(item.Enabled) </td> </tr> } </table>

基本types的ASP.NET MVC 4编辑器模板

我已经创build了一个数字input模板,如果我这样做 @Html.EditorFor(model => model.SomeValue, "Number") 它工作正常,模板使用。 但是,这是行不通的: @Html.EditorFor(model => model.SomeValue) 为什么我需要为基本types指定编辑器模板的名称?