这是Jquery代码。在此我试图将formlist传递给FormDetail.cs类的formlist List
$("#btnPrintAll").click(function () {
var formlist = [];
var empcd = $("#ddlEmp").val();
$(".frmcheck:checked").each(function () {
formlist.push({
FormID: $(this).data("formid"),
Area: $(this).data("area"),
Controller: $(this).data("controller"),
Action: $(this).data("action"),
empcd: empcd
});
});
$.ajax({
url: '@Url.Action("Getallviews", "PCM", new { area = "PBPCM" })',
type: "Get",
datatype: "HTML",
data: { form: formlist },
contentType: 'application/json;',
success: function (result) {
$("#dialog").html(result);
},
error: function () {
alert("Something Went Wrong. Please try after some time.");
}
});
});
这是FormDetail.cs
public class FormDetail
{
public string empcd { get; set; }
public string FormName { get; set; }
public string FormID { get; set; }
public string Area { get; set; }
public string Controller { get; set; }
public string Action { get; set; }
public List<FormDetail> formlist { get; set; }
}
这是Controller中的操作
public ActionResult Getallviews(List<FormDetail> form)
{
FormDetail model=new FormDetail();
model.formlist = form;
return PartialView("_pdfOfAllForms",model);
}
我在Controller中的表单列表中得到Count = 2,但是所有空值。请告诉我我错在哪里。 提前谢谢!