1
 <asp:ScriptManager ID="ScriptManager1" runat="server"/>
 <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
<ProgressTemplate>
<asp:Image ID="Image1" ImageUrl="waiting.gif" AlternateText="Processing" runat="server" />
</ProgressTemplate>
</asp:UpdateProgress>
 <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
 <ContentTemplate>
 <asp:ImageButton ID="imgBtn_PDF" runat="server" ImageUrl="../images/pdf.png" Width="34" Height="17" Style="padding-top: 7px"  OnClick="imgBtn_PDF_Click"   />
  </ContentTemplate>
  <Triggers>
 <asp:PostBackTrigger ControlID="imgBtn_PDF" />
 </Triggers>
 </asp:UpdatePanel>  

In the above code am using the update panel i am displaying waiting message with progress bar while exporting to PDF.The image is displayed when i use the trigger as asynchronous postback but am not able to export to PDF.But when use postbacktrigger am not able to display the waiting message.Below is my codebehind code to export to excel  

Response.ContentType = "application/pdf";
                Response.AddHeader("content-disposition", "attachment; filename=" + Path.GetFileName(pdfFile));
                sourceFile = new FileStream(pdfFile, FileMode.Open);
                long FileSize;
                FileSize = sourceFile.Length;
                byte[] getContent = new byte[(int)FileSize];
                sourceFile.Read(getContent, 0, (int)sourceFile.Length);
                sourceFile.Close();
                Response.BinaryWrite(getContent);

在上面的代码中,我添加了一个 PDF 类型的标题,以打开模式打开文件并将内容存储在字节的 getContent 中,然后通过字节读取整个文件并通过 BinaryWrite 导出

4

0 回答 0