kristofdielis
Programmer
- Sep 1, 2011
- 25
Hi,
I have a JS function that posts a contractcode + an array of a ComplexType to the server:
If I uncomment that prompt I get this result:
Content-wise that's correct and as far as I know it's also correct from a technical viewpoint.
Yet, at the Controller method, I get an object instance that is declared, but contains nulls. Code:
That UICreateSingleContractServiceCatalogue is defined like this:
So, I get a correct instance of this class, but with both ContractCode and Lines containing null.
-
I sort of broke it by adding the ContractCode, because before I did that the Lines array was filled in with a correct number of lines, though the values at server side were 0.
Any ideas on how to fix this? Thx.
I have a JS function that posts a contractcode + an array of a ComplexType to the server:
Code:
function PostContractServiceCatalogue(contractCode, lines) {
var dto = { "contractCode": contractCode, "lines": lines };
//prompt("", JSON.stringify(dto));
$.ajax({
type: 'POST',
url: "/ContractServiceCatalogue/CreateSingleContractServiceCatalogueLines",
dataType: "html",
data: dto,
success: function (returnPayload) {
SetActionResultHtml(returnPayload);
HideActionResult();
},
error: function (xhr, ajaxOptions, thrownError) {
alert("request failed: " + thrownError);
}
});
}
If I uncomment that prompt I get this result:
Code:
{"contractCode":"CODE","lines":[{"Id":"97","Quantity":"-1","Price":"-1"},{"Id":"93","Quantity":"-1","Price":"-1"},{"Id":"94","Quantity":"10","Price":"10"},{"Id":"95","Quantity":"-1","Price":"-1"}]}
Content-wise that's correct and as far as I know it's also correct from a technical viewpoint.
Yet, at the Controller method, I get an object instance that is declared, but contains nulls. Code:
Code:
[HttpPost]
public ActionResult CreateSingleContractServiceCatalogueLines(UICreateSingleContractServiceCatalogue lines)
{
var dtoActionResult = new DtoActionResult();
return PartialView("BusinessActionResultDisplayer", dtoActionResult);
}
That UICreateSingleContractServiceCatalogue is defined like this:
Code:
public class UICreateSingleContractServiceCatalogue
{
public string ContractCode { get; set; }
public DtoNewContractServiceCatalogueLine[] Lines { get; set; }
}
So, I get a correct instance of this class, but with both ContractCode and Lines containing null.
-
I sort of broke it by adding the ContractCode, because before I did that the Lines array was filled in with a correct number of lines, though the values at server side were 0.
Any ideas on how to fix this? Thx.