My Action:
public JsonResult SalvarCadastro(ListaModelView model)
{ }
My Model:
public string Assunto { get; set; }
public string Mensagem { get; set; }
public List<ContatosEmailModelView> Lista { get; set; }
My Js: The input's form is Subject and Message. List this out of form in a Table:
var dados = $("#form-envio-manual-cadastro").serialize();
$("#lista tr").each(function () {
var linha = [];
var tableData = $(this).find('td');
if (tableData.length > 0) {
tableData.each(function () { linha.push($(this).text()); });
lista.push({ Email: linha[0], Contato: linha[1] });
}
});
var list = '';
$.each(lista, function (key, value) {
list += encodeURIComponent($.param(lista[key])) + ';';
});
dados += '&Lista={' + list + '}';
When calling the action passing data as a parameter, it is not populating the List property, just Subject and Email. How do I populate a List property?