如何使用ActionResult返回null

时间:2018-07-04 13:01:17

标签: asp.net-mvc actionresult

我正在使用ajax调用来保存数据并打印收据。 我的ajax电话是

$.ajax({
    type: "POST",
    url: "/Payments/AddPayment",
    data: frm,
    dataType: "json",
    success: function (objData) {
        //ResetFormData();

        if (objData.AMENDEDBY == "") {
            strMsg = "Added Sucessfully";
        }
        else {
            strMsg = "Updated Sucessfully";
        }
        AlertData(strMsg, "Payments", "success");

        window.location.assign("/Report/PrintReport?objData=" + objData.REFNO);
    }

});

准确保存的数据,之后我要打印保存的数据。 我正在使用

window.location.assign("/Report/PrintReport?objData=" + objData.REFNO);

我的晶状体报告的控制器代码是

     public ActionResult PrintReport(string objData)
    {
        try
        { 
        //Report Object
        ReportDocument rd = new ReportDocument();
        rd.Load(Path.Combine(Server.MapPath("~/Reports/Accounts"), "CrystalReport1.rpt"));
        rd.RecordSelectionFormula = "{TBL_ACC_VOUCHERS_MASTER.REFNO}='" + objData + "'";

        //Report Connection object
        ReportRepo objReport = new ReportRepo();
        rd = objReport.GetReportConnections(rd);

        //Print Report Direct to Default Printer
        PrintDocument pdoc = new PrintDocument();
        string PrinterName = pdoc.PrinterSettings.PrinterName;
        rd.PrintOptions.PrinterName = PrinterName;
        rd.PrintToPrinter(1, true, 0, 0);
        return new EmptyResult();
        }
        catch
        {
            throw;
        }
    }

报告成功打印,但作为回报,我得到了带有重置值的默认视图。我希望得到相同的视图而没有任何更改。

我也用过

return Redirect(HttpContext.Request.UrlReferrer.AbsoluteUri);

但结果相同

0 个答案:

没有答案