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)
{
//
}
"Steven Cheng[MSFT]" <st*****@online.microsoft.comwrote in message
news:lo**************@TK2MSFTNGHUB02.phx.gbl...
Hello lmttag,
Regarding on such waring page for longrun task, in ASP.NET, we have the
following approachs so far:
1. Start the server-side long run task in a certain postback event, and
then in client-side page, use script (or html <metatag) to constantly
postback the page to check for the server-side task status(use session
variable ). If the task finished, stop those constantly postback script
and
display final result.
2. During the time without ajax, we have the option to use some
client-side
XMLHttp post component to send http request to server-side(to poll status
of the server-side long run task). This way, we can avoid constantly
refreshing the web page(as #1 does).
here are some web articles introduced some of such approaches:
#How To: Submit and Poll for Long-Running Tasks
http://msdn2.microsoft.com/en-us/library/ms979200.aspx
#Building a Better Wait Page
http://www.codeproject.com/aspnet/wait_page.asp
#Solve the Page Waiting Game with Threaded AJAX
http://www.devx.com/asp/Article/29617
3. Nowadays, we have the AJAX based pattern, it is somewhat like the #2,
but leverage existing ajax components. The microsoft AJAX framework just
provide such a well encapsulated AJAX framework that can help us build
AJAX
web application. Here for long run task, you can start it in a certain
postback event, and then let the client-side call a AJAX webservice
function to constantly poll the status of the server-side task.
Here are reference about calling webservice in ASP.NET ajax
application(and
the whole tutorial):
#Calling Web Services from Client Script in ASP.NET AJAX
http://ajax.asp.net/docs/tutorials/C...XTutorial.aspx
>
#ASP.NET AJAX Roadmap
http://ajax.asp.net/docs/default.aspx
Hope this helps. if you have any more specific questions, welcome to
discuss here also.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no
rights.
>