4
Good afternoon, I am passing a list of JS objects to C#, to a Webmethod, as function parameter, what kind of parameters this should 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 the 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 'salvaReg' server method failed with the following error: System.Invalidoperationexception-- The 'Gradual.Web.serializeItens' type is not supported for deserialization of an array.
How is your AJAX call being made? You could post the code?
– Miguel Angelo
Sure.. Pagemethods.salvaReg(oMov, itensList, salvaReg_cb);
– William de Castro
It would have to be the ajax call itself:
$.ajax(...
– Miguel Angelo