0
私はEditorTemplateを作成しEditorTemplate。コードで</p> <p><img src="https://i.stack.imgur.com/FNOz8.png" alt="enter image description here"></p> <p>:MVC3
@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; }
}
}
しかし、私はページでエディタを見ることができません...なぜですか?
にそれは私が必要とまさにません。そして、最後に、それは動作しません。 – korovaisdead
あなたの期待どおりの結果は? – Shyju
このContactsViewModelから1つ以上の電話を追加できます。 – korovaisdead