我创建了 EditorTemplate:
带代码:
@model RentSite.Web.UI.Models.PhonesViewModel
<div>
@Html.TextBoxFor(m=>Model.Number) @Html.TextBoxFor(m => Model.From) @Html.TextBoxFor(m => Model.To)
</div>
我尝试像这样使用它:
@model RentSite.Web.UI.Models.ContactsViewModel
@{
ViewBag.Title = "AddContact";
}
<h2>AddContact</h2>
@using (Html.BeginForm("AddContact","Contact",FormMethod.Post, new {enctype = "multipart/form-data"}))
{
<input type="file" name="Image"/>
@Html.EditorFor(model=>model.Phoness )
<input type="submit" value="Add"/>
}
ContactsViewModel 如下所示:
namespace RentSite.Web.UI.Models
{
public class ContactsViewModel
{
public string Name { get; set; }
public IEnumerable<PhonesViewModel> Phoness { get; set; }
}
}
但是我在页面上看不到任何编辑器...为什么?