I have a template
<script id="template" type="text/x-jquery-tmpl">
<div class="experience">
<label for="c${count}">New Thing:</label>
<input type="text" id="c${count}" name="Fund[${count}].Name" />
<label for="c${count}">New Thing count:</label>
<input type="text" id="c${count}" name="Fund[${count}].FundNo" />
</div>
to which I add controls dynamically to a div container.
I have a model in my mvc application
[Serializable]
public class Step2ViewModel : IStepViewModel
{
[Required]
public List<FormTest.Models.Item> Things;
}
[Serializable]
public class Item
{
public string Name { get; set; }
public string Number { get; set; }
}
How do I bind these newly created controls to a model. Does that entail using @Html.LabelFor, @Html.TextBoxFor etc in my template?
thanks!
Edit:
Just in case the question is open to interpretation - I want to bind dynamically created controls ( which was done using templ() ) to the List in my model when the form is posted.