I generate a number of textbox based on the number of element in a list.
The model :
public class MyModel
{
public List<Language> Languages { get; set; }
public string Code { get; set; }
}
public class Language
{
public int Id { get; set; }
public string Name { get; set; }
public string Code { get; set; }
public bool IsDefault { get; set; }
}
The view :
@model MyModel
<form id="formDetail">
@Html.TextBoxFor(m => m.Code)
@foreach (var item in Model.Language)
{
<input type="text" id="@item.Code"/> //the code are : FR, EN, GE, ...
}
</form>
I post the form (POST) with Ajax.
Controller :
[HttpPost]
public ActionResult Save(MyModel myModel)
{
..
}
The number of textbox can be different depending of the number of language in the Language list. Could you tell me how get the value of these textboxes in the controller
Thanks,