Please forgive me if this question is a duplicate, because I could not find the answer to this question anywhere else on Stack Overflow.
I have a form in ASP.NET that has multiple fields, and more fields can be added through jQuery. In my form, I want an array of friends.
This is the friend class:
public class Friend {
public string Name { get; set; }
public int Age { get; set; }
}
This is my form, and users can add as many friends as they want, by clicking a button that adds a row with these two fields. For example:
<table>
<tr>
<input type="text" name="friend[0].Name" />
<input type="text" name="friend[0].Age" />
</tr>
<tr>
<input type="text" name="friend[1].Name" />
<input type="text" name="friend[1].Age" />
</tr>
<tr>
<input type="text" name="friend[2].Name" />
<input type="text" name="friend[2].Age" />
</tr>
...
</table>
How would I access these as a list of friends, in my function in the controller?