Я хочу, чтобы текстовое поле, привязанное к массиву, отправляло форму при ее изменении.
Я следил за этим сообщением , чтобы заставить его работать, но свойство в моей моделивсегда ноль. Почему?
Модель
public class TestModel
{
public int[] MyInts;
}
Контроллер
public ActionResult Index(TestModel model)
{
if (model.MyInts == null) // <-- Always true
{
model.MyInts = new int[] { 1, 2, 3, 4 };
}
}
Вид
@model TestModel
@using (Html.BeginForm("Index", "Test", FormMethod.Post, new { id = "TestForm" }))
{
<table class="table">
<thead>
<tr>
<th />
@for (int i = 0; i < Model.MyInts.Count(); i ++)
{
<th>
@Html.TextBoxFor(x => Model.MyInts[i], new { onchange = "this.form.submit();" })
</th>
}