S
S
Sergey Korolkov2019-02-01 05:04:15
ASP.NET
Sergey Korolkov, 2019-02-01 05:04:15

What should be the model for this view?

View with identical inputs:

@using (Html.BeginForm(" ", "Home", FormMethod.Post))
}
   @Html.EditorFor(model => model.Field)
   @Html.EditorFor(model => model.Field)
   @Html.EditorFor(model => model.Field)
   <input type="submit" value="save">
}

The number of inputs can be as many as you like, because JS adds them, but they are all identical.
I just need to send the completed form model to the controller using the Post method. Only I cannot create the model itself for this case to be used by the view. Or you can populate model properties without EditorFor().

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Korolkov, 2019-02-01
@vhelsing90

I solved the issue, it's just that EditorFor cannot define an array of data in the model, you have to use TextBoxFor and catch them in the controller as an array of data.

D
Dmitry Kovalsky, 2019-02-01
@dmitryKovalskiy

Make a HiddenFor for the data array, and in JS form this array and write it to the hidden field.
Or do you have each field has its own purpose, and not just an array of values?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question