0
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: Form input is Subject and Message. Lists this out of the 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 by passing data as parameter, it is not filling the List property, only subject and email. How do I fill a List property?
The result given is: "Title=&Subject=&Message=&Newmail=&Name=&Registration=&List={Email%3Dtest%2540email.com.br%26Contact%3DJuracil%2Bereira;Email%3Dmaria%2540email.com%26Contact%3DMaria%2BTeixeira;}"
– Andersson OS
but in this result the list is filled with the emails and names
– Wees Smith
But in the action the Model List property is Count = 0
– Andersson OS
If passing as string works?
– Wees Smith
I don’t understand Wees. It passes string like?
– Andersson OS
in the model you are passing as
list
, forehead pass asstring
– Wees Smith