I have a painfully simple view model
public class TellAFriendViewModel
{
public string Email1 { get; set; }
public string Email2 { get; set; }
pu
Unless i'm missing something, I don't know why no-one has suggested this. Why is everyone looping and/or using reflection??
public class TellAFriendViewModel
{
public ICollection Emails { get; set; } // populate 5 of them in ctor or controller
}
public class EmailViewModel
{
public string Email { get; set; }
}
View:
@using (Html.BeginForm()){
@Html.AntiForgeryToken()
@Html.EditorFor(model => model.Emails)
}
EditorTemplates\EmailViewModel.cshtml
@Html.TextBoxFor(model => model.Email)
Loops are NEVER required in MVC. I repeat. NEVER