I have a Form which will dynamically add textboxes for a particular database field. I wanted to use Model Binding to retrieve values from the Form on a Controller. I know Model Binding uses the textbox's id to retrieve values. However it's never recommended to have multiple textboxes with same ID as its unique. I have it such that in case a user needs more textboxes for the same field, they can add them dynamically by clicking a button. How do I retrieve values from these textboxes? Is there a way I can use html classes with model binding to retrieve the values instead? Or should I do it like this
public ActionResult MyAction(FormCollection form)
{
// ModelBinder will set "form" appropriately
foreach(var value in form.Getvalues("duplicatedFieldId"))
{
//do something with value
}
}
Regards