ASP.NET Webforms目标.NET 4。 我需要在页面上显示一个pdf文档(在iframe中),加载pdf会花费很多时间,所以想法是加载pdf文档异步并在iff中显示等待消息,一旦pdf准备就绪,在iframe中显示pdf。
// PrintPDFView.aspx
<div id="pdfDiv" style="height: 100%;">
// show pdf if ready otherwise waiting message
<iframe runat="server" width="100%" height="100%" id="PDFViewDoc" />
</div>
// PrintPDFView.aspx.cs
protected override void OnPreRender(EventArgs e)
{
//...
// Long running process
CallDocumentsService();
//...
PDFViewDoc.Attributes["src"] = "ShowPDFView.aspx";
}
// ShowPDFView.aspx
// When the pdf is ready, it will be rendered on this page
<body>
<div id="LoadingPdf">
<h1>Loading your document!</h1>
<p>This may take a few minutes...</p>
</div>
</body>
// ShowPDFView.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
// ...
Response.BinaryWrite(pdfToDisplay);
//...
}