Steven,
Thank you for the information. It was very helpful.
I was able to get the 3rd option (ASP.NET AJAX) pattern working for a simple
situation. However, my situation is a bit more complex and I'm not sure how
to use the AJAX pattern and make it work. So, I was hoping that I could
give you some more info. and check to see if you could assist me.
As I mentioned in my original post, I have a page that opens another page
using the JavaScript window.open function. In the second page, I have no
controls, no buttons (no buttons to click to cause a postback), no div tags,
etc. What I'm doing in the second page is generating a SQL Server 2005
Reporting Services report, rendering it as PDF, and displaying the PDF in
the second page's browser.
For some reports, this generating/rendering of the report can take maybe 20
seconds. So, I need the page to display an animated gif with a message that
says "Please wait..." while, in the background, the report is being
generated. Then when the report is done being generated/rendered, I need
the animated gif and wait message to go away and have the PDF report
displayed.
I hope this makes sense. Would you be able to provide some suggestions/help
with this situation?
Here's some code snippets from my second page that is generating, rendering,
and displaying the report.
(Nothing in the markup for the page.)
<html xmlns="
http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Generated Report</title>
<link href="../CSS/ReportsStyleSheet.css" rel="Stylesheet"
type="text/css" />
</head>
<body>
<form id="formRenderReport" runat="server">
<div>
</div>
</form>
</body>
</html>
(The code-behind...)
public partial class Pages_RenderReport : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
AddOnPreRenderCompleteAsync(new
BeginEventHandler(BeginAsyncOperation), new
EndEventHandler(EndAsyncOperation));
}
}
private System.IAsyncResult BeginAsyncOperation(object sender, EventArgs
e, AsyncCallback cb, object state)
{
// ...
// Connect to Reporting Services
ReportingExecution.ReportExecutionService rs = new
ReportingExecution.ReportExecutionService();
rs.Credentials =
System.Net.CredentialCache.DefaultCredentials;
// Local Reporting Services variables
byte[] result = null;
string format = "PDF";
string format = outputformat;
string historyID = null;
string devInfo = null;
string encoding;
string mimeType;
string extension;
ReportingExecution.Warning[] warnings = null;
string[] streamIDs = null;
// ...
try
{
// Set all the Reporting Services variables and
parameters and render the report
ReportingExecution.ExecutionInfo execInfo = new
ReportingExecution.ExecutionInfo();
ReportingExecution.ExecutionHeader execHeader = new
ReportingExecution.ExecutionHeader();
rs.ExecutionHeaderValue = execHeader;
execInfo = rs.LoadReport(reportPath1, historyID);
rs.SetExecutionParameters(parameters, "en-us");
System.String SessionId =
rs.ExecutionHeaderValue.ExecutionID;
result = rs.Render(format, devInfo, out extension, out
mimeType, out encoding, out warnings, out streamIDs);
execInfo = rs.GetExecutionInfo();
// Force the render out of the report to the browser
Response.Clear();
Response.ClearContent();
Response.ClearHeaders();
Response.AppendHeader("content-length",
result.Length.ToString());
switch (outputformat)
{
case "EXCEL":
Response.ContentType =
"application/vnd.ms-excel"; // Seems to work
break;
case "MHTML":
Response.ContentType = "message/rfc822";
break;
case "PDF":
Response.ContentType = "application/pdf";
break;
default:
Response.ContentType = "application/pdf";
break;
}
Response.BinaryWrite(result);
Response.Flush();
Response.Close();
Response.End();
}
catch (System.Exception ex)
{
// An exception occurred while trying to generate and
render the report
}
// Just needed to get a IAsyncResult to return
System.Net.WebRequest hwr =
System.Net.WebRequest.Create("
http://localhost/");
return hwr.BeginGetResponse(cb, state);
}
private void EndAsyncOperation(System.IAsyncResult ar)
{
//
}