5
Answers

Export Data is not working.

Sathish Kumar

Sathish Kumar

9y
600
1
Hi,
 
            I wanna export the data into PDF/EXCEL. for PDF i'm using iTextSharp.dll, for EXCEL  using HtmlTable. I wanna export the data using Ajax post.
 
            Scenario:
 
            I've a seperate button for Export data into Excel and PDF, when i click the button i wanna download the files appropriately without page load, so i've used the Ajax post method. the method was successfully called. but the files are not downloaded. can anyone assist me to get the solution.
 
 
My .aspx code:
 
<asp:Button ID="btnPDF" runat="server" Text="PDF" ToolTip="Download the PDF" onclick="btnPDF_Click" /> 
<asp:Button ID="btnEXECL" runat="server" Text="EXCEL" ToolTip="Download the EXCEL" onclick="btnEXECL_Click" />

Script Code:
$("input[type='submit']").click(function (e) { 
            var type = $(this).val();
            var url = "DownloadFile.aspx?type=" + type; 
            $.post(url);
});
These code are placed inside the default.aspx page.
From here i've called the "DownloadFile.aspx" using post method. the method is called and the files have been created but not download at the end.
 
 
Answers (5)