0
сервер:может по умолчанию модель связующего генерировать IEnumerable <FormItem>?
public class FormItems
{
public IEnumerable<MyClass> Values { get; set; }
}
клиент:
<form id="myform" action="/" method="post">
<!-- Those inputs could be added dynamically -->
<input type="text" name="[0].Value" />
<input type="text" name="[1].Value" />
<input type="text" name="[2].Value" />
<input type="text" name="[3].Value" />
<button type="submit">OK</button>
</form>
и, наконец, AJAXify формы:
$(function() {
$('#myform').submit(function() {
var form = $(this);
$.ajax({
url: form.attr('action'),
type: form.attr('method'),
data: form.serialize(),
success: function(result) {
}
});
});
});
Как я могу использовать по умолчанию модель связующему получить Аякс данных в строго типизированных IEnumerable?
[HttpPost]
public JsonResult Save(FormItems data)
Все зависит от того, как именно вы структурированы в представлении. Можете ли вы разместить HTML-код в своем представлении? – mattytommo