我正在尝试使用 UpdatePanel 和 Updateprogress 在创建和刷新 PDF 时显示等待消息。查看代码
<asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
<ProgressTemplate>
Loading.......
</ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="BT_Create" />
</Triggers>
<ContentTemplate>
<asp:LinkButton ID="BT_Create" runat="server" OnClick="BT_Create_Click">Download</asp:LinkButton>
</ContentTemplate>
</asp:UpdatePanel>
protected void BT_Create_Click(object sender, EventArgs e)
{
byte[] downloadBytes = pdfConverter.GetPdfBytesFromHtmlString(htmlCodeToConvert, baseUrl);
System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;
response.Clear();
response.AddHeader("Content-Type", "binary/octet-stream");
response.AddHeader("Content-Disposition", "attachment; filename="test.pdf; size=" + downloadBytes.Length.ToString());
response.Flush();
response.BinaryWrite(downloadBytes);
response.Flush();
response.End();
}
问题是我可以让等待消息出现,但没有返回 PDF:S。在这件事上有什么帮助吗?
干杯。