Good afternoon, I am passing a list of objects from JS to C #, to a WebMethod, as a function parameter, what kind of parameters should this be?
I created a class to receive the data:
public class serializeItens {
//Dados de itens
public RowGrid [] sXmlItens { get; set; }
}
public class RowGrid {
public decimal ItemID { get; set; }
public string itemName { get; set; }
public string itemUnid { get; set; }
public decimal itemQtd { get; set; }
public decimal itemCust { get; set; }
public string itemIL { get; set; }
public string itemCentr { get; set; }
public decimal itemSaldo { get; set; }
public RowGrid() {
ItemID = 0;
itemName = string.Empty;
itemUnid = string.Empty;
itemQtd = 0;
itemCust = 0;
itemIL = string.Empty;
itemCentr = string.Empty;
itemSaldo = 0;
}
}
With exactly the same arguments I'm going through in JS ..
var oItem = {
Codig: 0,
Desc: "",
Unid: "KG",
Quant: 0,
Custo: 0,
IL: "",
Centro: "",
Saldo: 0
}
itensList.push(oItem);
But when I call WebMethod via ajax:
[WebMethod(EnableSession = true)]
public static bool salvaReg(EstoqMov PoMov, serializeItens PsItens) {
Returns the following error message:
Sys.Net.WebServiceFailedException: The server method 'salvaReg' failed with the following error: System.InvalidOperationException-- The 'Gradual.Web.serializeItems' type is not supported for deserialization of an array. em>