0

My page has a pop-up. The button on popup generates and downloads Aspose excel file. (The page also has Ajax settings)

Now after file download, my button is disabled and nothing else works on page unless i refresh it manually.

Popup on page

<div class="modal hide" id="AwaitPracSignoffReportModal">
    <div class="modal-header">
        <a class="close" data-dismiss="modal">×</a>
        <h3>
            <asp:Label runat="server" ID="lblPopupHeading" Text="Awaiting Practice Sign-off Report" /></h3>
    </div>
   <!-- Other asp controls in popup-->

    <div class="modal-footer" style="margin-bottom: 5px">
        <button class="btn" data-dismiss="modal">
            Cancel</button>
        <asp:Button runat="server" ID="btnGenerateReport" CssClass="btn btn-primary"
            Text="Generate Report" ValidationGroup="ReportModal" OnClientClick="javascript:setFormSubmitToFalse();" />
    </div>

</div>

Script

function HideGenerateReportPopup() {
            $('#AwaitPracSignoffReportModal').modal().hide();
        }

        function setFormSubmitToFalse() {
            setTimeout(function () { _spFormOnSubmitCalled = false; }, 3000);
            return true;
        }

CodeBehind

btnGenerateReport.Click += (s, ev) =>
        {
            this.Presenter.ExportToExcel();

            ScriptManager.RegisterStartupScript(this, this.GetType(), "Generate Report", "HideGenerateReportPopup();", true);
        };

Presenter Code (different project)

 Aspose.Cells.Workbook workbook = new Aspose.Cells.Workbook();
        int worksheetNo = 0;

        foreach (System.Data.DataTable dt in ds.Tables)
        {
            Aspose.Cells.Worksheet worksheet = workbook.Worksheets[worksheetNo];

            worksheet.Cells.ImportDataTable(dt, true, "A1");
            worksheet.AutoFitColumns();
            worksheetNo++;
        }

        workbook.Save(HttpContext.Current.Response, filename, ContentDisposition.Attachment, new XlsSaveOptions(SaveFormat.Excel97To2003));

            HttpContext.Current.Response.Flush();
        HttpContext.Current.Response.End();

I have added setFormSubmitToFalse function as recommended here. If I try to add AjaxSettings for the btnGenerateReport, it gives script error

Uncaught Error: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.

When i remove it, the page stays as is and no more contols work.

Samra
  • 1,815
  • 4
  • 35
  • 71
  • Aspose.Cells allows you to save the Workbook object in Byte Array i.e. byte[]. It seems, this issue is not related to Aspose.Cells. But if you think, it is because of Aspose.Cells, then please submit your ASP.NET web application project. It should be simpler without any business logic and it should replicate the issue. Another way is that you save your workbook in byte[] and send those bytes to response stream yourself. It will help you narrow down the issue and you will come to know ... – shakeel May 29 '18 at 09:15
  • ....you will come to know if your issue is occurring because of Aspose.Cells or because of some other problems relating to HTML, JavaScript, ASP.NET etc. --- Note: I am working as Developer Evangelist at Aspose. – shakeel May 29 '18 at 09:15

1 Answers1

0

Found my answer here

the page and the PDF. You can't do that. Typically download pages start a download as a separate request when you've gone to them (via JavaScript, I believe), with a direct link just in case the JavaScript doesn't work.

Now i have added a separte page (ashx) and open it in a separate tab.

Samra
  • 1,815
  • 4
  • 35
  • 71