473,473 Members | 1,895 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to display page while long-running process executing?

Hello.
We're developing an ASP.NET 2.0 (C#) application and we're trying to
AJAX-enable it. We're having problem with a page not showing the page while
a long-running process is executing. So, we're looking for a way to display
the page with a "please wait..." message while the process is running, and
then, when the process is done, update the page with the actual results/page
content.

We have a page that opens another browser/page using JavaScript window.open,
and, in the second page's Page_Load, we call the long-running function. In
doing this, the browser and page do not completely render anything until the
long-running function is complete.

So, how can we make the page that calls the long-running process in
Page_Load display a page with some sort of please wait... message (and
probably an animated gif) while the function runs?

Is there something in the new ASP.NET AJAX stuff? Or, is there some other
way?

Thanks.
Mar 15 '07 #1
14 23100
Create a layer (DIV) and make it visible. It says "please wait". At the end
of the render (bottom of HTML page), output JavaScript that hides the div.
That is the basic mechanics. I do not have a sample. :-(

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
"lmttag" wrote:
Hello.
We're developing an ASP.NET 2.0 (C#) application and we're trying to
AJAX-enable it. We're having problem with a page not showing the page while
a long-running process is executing. So, we're looking for a way to display
the page with a "please wait..." message while the process is running, and
then, when the process is done, update the page with the actual results/page
content.

We have a page that opens another browser/page using JavaScript window.open,
and, in the second page's Page_Load, we call the long-running function. In
doing this, the browser and page do not completely render anything until the
long-running function is complete.

So, how can we make the page that calls the long-running process in
Page_Load display a page with some sort of please wait... message (and
probably an animated gif) while the function runs?

Is there something in the new ASP.NET AJAX stuff? Or, is there some other
way?

Thanks.
Mar 15 '07 #2
re:
!So, how can we make the page that calls the long-running process in
!Page_Load display a page with some sort of please wait... message (and
!probably an animated gif) while the function runs?

Check out the code samples in Chapter 3 :

http://www.daveandal.net/books/6744/samples.aspx


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"lmttag" <lm****@newsgroup.nospamwrote in message news:u9**************@TK2MSFTNGP04.phx.gbl...
Hello.
We're developing an ASP.NET 2.0 (C#) application and we're trying to
AJAX-enable it. We're having problem with a page not showing the page while
a long-running process is executing. So, we're looking for a way to display
the page with a "please wait..." message while the process is running, and
then, when the process is done, update the page with the actual results/page
content.

We have a page that opens another browser/page using JavaScript window.open,
and, in the second page's Page_Load, we call the long-running function. In
doing this, the browser and page do not completely render anything until the
long-running function is complete.

So, how can we make the page that calls the long-running process in
Page_Load display a page with some sort of please wait... message (and
probably an animated gif) while the function runs?

Is there something in the new ASP.NET AJAX stuff? Or, is there some other
way?

Thanks.


Mar 15 '07 #3
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.

Mar 16 '07 #4
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.
>

Mar 17 '07 #5
Hello lmttag,

Thanks for your reply.

From the page code you provided, you're currently using the asynchronous
page execution model. I think for your scenario, you do not need to use
this asynchronous executing model. Actually, you can consider using a
separate thread(manually created) to execute those code that access the
backend report server and generate the report output. Thus, your main page
can simply use synchronous page execution model(do not use async page), and
when it postback to start generating the report, it will create a new
thread to do the report generation and the page will return to client
immediately after start the new thread and display a label(show "report is
being generated......"), and the client page will use AJAX script to
constantly call a server-side webservice to check whether the report result
has been generated(by checking a session variable). If report has been
generated, it submit the page and the page render out the report content
(generated by the separate thread in the former stage). How do you think of
this?

If you still have any question or any further concern here, please feel
free to let me know.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.


Mar 19 '07 #6
Hello again Steve,
Thank you so much for the information and suggestions. I'm going to look
into implementing your suggestions, although some other "fires" have come up
here that I'll need to take care of first. I'll probably be writing you
again for some more assistance, unless you have some code examples to get me
started.
Thanks again!

"Steven Cheng[MSFT]" <st*****@online.microsoft.comwrote in message
news:zn**************@TK2MSFTNGHUB02.phx.gbl...
Hello lmttag,

Thanks for your reply.

From the page code you provided, you're currently using the asynchronous
page execution model. I think for your scenario, you do not need to use
this asynchronous executing model. Actually, you can consider using a
separate thread(manually created) to execute those code that access the
backend report server and generate the report output. Thus, your main page
can simply use synchronous page execution model(do not use async page),
and
when it postback to start generating the report, it will create a new
thread to do the report generation and the page will return to client
immediately after start the new thread and display a label(show "report is
being generated......"), and the client page will use AJAX script to
constantly call a server-side webservice to check whether the report
result
has been generated(by checking a session variable). If report has been
generated, it submit the page and the page render out the report content
(generated by the separate thread in the former stage). How do you think
of
this?

If you still have any question or any further concern here, please feel
free to let me know.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no
rights.
>

Mar 20 '07 #7
Thanks for your reply Imttag,

Nevermine, please feel free to take care of your most priority work and
followup here at your convenience. I can create a simple demo page (through
the ASP.NET AJAX framework) that shows how to display waiting message while
waiting for server-side long run processing. I'll posted code here later,
if you feel necessary, I can also emai the code to you.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

Mar 22 '07 #8
Steven,
Hi. Thanks for all your help. I'm done with the other stuff I was working
on, so I'm now back to this showing progress issue.

I've been trying to do what you suggested in your previous post. However, I
guess I'm not that familiar with AJAX and threading yet because I can't get
it to work.

I'm having trouble creating a new thread and having the new thread able to
access the Response object (which I guess it can't). Also, I'm having
troubles because the Reporting Services render method returns a byte[] and
all the AJAX examples simply pass/return strings. My situation is a bit
more complex.

Anyway, I'd greatly appreciate any examples and/or demo code that could
possibly show me (or give me some tips) on how to accomplish my task.

Thanks again.

"Steven Cheng[MSFT]" <st*****@online.microsoft.comwrote in message
news:T0**************@TK2MSFTNGHUB02.phx.gbl...
Thanks for your reply Imttag,

Nevermine, please feel free to take care of your most priority work and
followup here at your convenience. I can create a simple demo page
(through
the ASP.NET AJAX framework) that shows how to display waiting message
while
waiting for server-side long run processing. I'll posted code here later,
if you feel necessary, I can also emai the code to you.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no
rights.
>

Mar 23 '07 #9
Hi Imgtag,

I have just created a very simple test page through ASP.NET AJAX
application framework. It contains a page which postback and start a
background thread to process a longrun task. The page will return
immediately and use client script to constantly ping the server-side for
task status and postback again if the task is finished. Would you shot me
a mail so that I can send you the project via email? You can get me
through the email in my signature (remove "online")

If there is anything unclear, please feel free to let me know.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

Mar 26 '07 #10
Hi Steven,
I sent you an e-mail yesterday so that you would have my e-mail address to
send me your example project. But, I just wanted to follow up on this post
also. If you don't get my e-mail, let me know and I can re-send it.
Thanks.

"Steven Cheng[MSFT]" <st*****@online.microsoft.comwrote in message
news:rU*************@TK2MSFTNGHUB02.phx.gbl...
Hi Imgtag,

I have just created a very simple test page through ASP.NET AJAX
application framework. It contains a page which postback and start a
background thread to process a longrun task. The page will return
immediately and use client script to constantly ping the server-side for
task status and postback again if the task is finished. Would you shot me
a mail so that I can send you the project via email? You can get me
through the email in my signature (remove "online")

If there is anything unclear, please feel free to let me know.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no
rights.
>

Mar 27 '07 #11
Hi Imttag,

I have received your email and replied you with the test project/page in
the attachment. Please let me know if you get the reply and if you have any
further questions or anything we can help, please feel free to let me know.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

Mar 28 '07 #12
Hi Imttag,

Just a continue followup to see how are you doing on this issue? Does the
test sample provide you some idea on this? If there is anything else we can
help, please don't hesitate to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

Apr 2 '07 #13
Hi Steve,
just wonder if you can post the code online. I have 1st page with a lot
of stuff. When I click a button on that page, it redirects to the 2nd
page. I need a "wait ..." on the 2nd page. The 2nd page has 2 buttons
and a gridview ( take 10 sec to show up). So I just wonder any simple
solution to display the message "wait..." for user to wait for the 2nd
page.
*** Sent via Developersdex http://www.developersdex.com ***
Apr 5 '07 #14
yes

please post

Apr 19 '07 #15

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: bala | last post by:
hi!!! i need to display a disclaimer which is two page in length in a word document. i also need to format the text. the idea is something as follows on opening the application, a form which...
5
by: Rajani | last post by:
Hello, I have a strange problem. I want to check the privilege of the login user on each page and allow to display if has suff. priv. I am storing the privilege is session variable. I am...
0
by: Glen | last post by:
Is there any way to post data to an ASP.Net form and then display the page to the user with the posted data from a client app? Here's what I'm trying to do: Serialize a business object (order)...
11
by: Laurent Compere | last post by:
Hi, I'm trying to do something I thought easy. Explanation : I've recently bought a Multimedia Player DVX-500E. This player is connected via ethernet on my local network et allows among other...
1
by: David Thielen | last post by:
Hi; I would like to display a page then immediately cause a post back (the 1st page will have a big "working..." on it, then in the post back do my query which will take a couple of seconds, and...
1
by: jmacduff | last post by:
I would like to be able to display page load times within our asp.net application for debugging purposes , I am seeing some random slowness in our application and a load time metric would really...
3
by: phil67b | last post by:
Hello everybody, I have a page rech.php where I'm doing a multi-criteria research Ex. choose your car model, choose your country. After validation of my form, on the same page, the lines will be...
1
by: Rohit | last post by:
I have a table on Web form. In a column, I want to display articles posted by other users. Which control should I use so that it can be linked with the SQL Server Table.
1
by: Jason | last post by:
I've got visual web developer, I've made my page and did Build Build Web site. The directory is in a directory that is a web server on my computer but every time I try to bring up for example: ...
0
tjc0ol
by: tjc0ol | last post by:
Hi guys, I'm a newbie of this stuffs, We had a small office network (1 Windows 2K - Server) and (3 Windows XP - Client). I am testing to 1 PC (Windows 2K) installed with Licensed Wingate...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.