Passing parameter to controller
Passing parameter to controller
alesk4
Posts: 2Questions: 1Answers: 0
Hello
I have web app mvc and using jquery datatables. I have a view which shows detail of some entity and i want to show data from another table paired with Id key in datatable.
In this view there is datatable with:
serverSide": true,
"ajax": {
"url": "Contracts/LoadContractNotes",
"type": "POST",
"datatype": "json",
"data": function (data) {
data.test = $('#test').val();
}
}
Value for "test" should be here
<input id="test" type="hidden" name="ContractId" value="@ViewBag.ContractId" />
In controller i use:
[HttpPost]
public IActionResult LoadContractNotes(){
.....
.....
}
I tried many thing to pass parameter "test" to LoadContractNotes so i would be able to use it for filtering data.
Could you please give me advice?
Thank you
A
This question has an accepted answers - jump to answer
Answers
If you have a look in the request parameters for the Ajax request in your browser's network inspector, you should be able to see the
test
parameter being submitted. Is that the case? If so, you should then be able to useRequest.Form["test"]
or similar to access the property. For the server-side of things, you'd need to refer to Microsoft's .NET documentation for more details.Allan
Hello Allan.
Thank you for aswer. Now it is working.