I have this problem: I want to store a list of phone numbers where the first is rended by default with a partial view, the others are created dynamically when I press a link (i.e.: Add Phone number)...
In order to do this, I created a template with the fields I use, that is the following:
<div class="editor-label">
@Html.Label("Contact type")
</div>
<div class="editor-field">
@Html.DropDownListFor(model => model.CatContact[0], (ViewData["catcontact"] as SelectList), "--- ")
</div>
<div style="clear: both;">
<div class="divpos" style="width: 760px !important;">
<div class="editor-label">
@Html.Label("Phone number")
</div>
<div class="editor-field">
@Html.EditorFor(model => model.PrefI[0]) <!--International prefix-->
@Html.ValidationMessageFor(model => model.PrefI[0])
@Html.EditorFor(model => model.PrefN[0]) <!--National prefix-->
@Html.ValidationMessageFor(model => model.PrefN[0])
@Html.EditorFor(model => model.Number[0]) <!--Phone Number-->
@Html.ValidationMessageFor(model => model.Number[0])
</div>
</div>
</div>
This partial view takes the following model
public partial class RegView1Model
{
public List<int> CatContact { get; set; }
public List<string> PrefI { get; set; }
public List<string> PrefN { get; set; }
public List<string> Number { get; set; }
}
I want to save all phone numbers at once. I've also tried to find a solution with jQuery, by adding all the rendered code with a simple copy/paste of the previous HTML, but of course it is not easy to maintain.
So my question is if it is possible to render the partial view each time I press a link in mvc3 with razor, increasing the index of the lists without using javascript (or jQuery)
Hope I've explained well my problem