0

i have this jquery function, it load a dialog and call the action in controller, but in controller don't arrive the value parameters (val)..

The action is called correctly because open the dialog e load the data in viewmodel.

I have create a object for pass the data (ActivityParameterVO actPar)

public class ActivityParameterVO
{
public decimal EOA_EVEOPTID { get; set; }
public decimal EOA_ACTID { get; set; }

......

}

This is the jquery function

parameters = function (EVEOPTID, ACTID) {

var val = {
'EOA_EVEOPTID' : EVEOPTID,
'EOA_ACTID' : ACTID
};

$("#dialog").dialog({

autoOpen: true, modal: true, height: 800, width: 1000, resizable: false,
open: function () {
console.log(JSON.stringify(val));
$.ajax({
type: 'POST',
data: JSON.stringify(val),
url: '/Event/LoadParameters',
contentType: "application/json"
}).done(function (res) {
$("#dialog").html(res);
$('#dialog').dialog('open');
});
},
position: {
my: 'top', at: 'top'
},
buttons: [
{
html: "Cancel",
"class": "btn btn-default",
click: function () {
$(this).dialog("close");
}
},
{
html: "<i class='fa fa-check'></i>&nbsp; OK",
"class": "btn btn-primary",
click: function () {
$(this).dialog("close");
}
}
]
})
};

The Action Metod

public IActionResult LoadParameters([FromBody] ActivityParameterVO actPar)
{
EventActivityParametersViewModel eventActivityParameters = this.eventStructureBLL.GetParameters("ITA", actPar1);


return PartialView("~/Views/Event/Parameters.cshtml", eventActivityParameters);
}
1
  • Noting, I change it but obtain null reference in action "LoadParameters([FromBody] ActivityParameterVO actPar) " Commented Oct 1, 2018 at 13:58

1 Answer 1

2

I had simply forgotten to mark with [httpPost] tha action method

**[httpPost]**
public IActionResult LoadParameters([FromBody] ActivityParameterVO actPar)
{
EventActivityParametersViewModel eventActivityParameters = this.eventStructureBLL.GetParameters("ITA", actPar);


return PartialView("~/Views/Event/Parameters.cshtml", eventActivityParameters);
}

Now it works

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.