473,701 Members | 2,663 Online
Bytes | Software Development & Data Engineering Community
+ 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 23159
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****@newsgro up.nospamwrote in message news:u9******** ******@TK2MSFTN GP04.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>Generate d Report</title>
<link href="../CSS/ReportsStyleShe et.css" rel="Stylesheet "
type="text/css" />
</head>
<body>
<form id="formRenderR eport" runat="server">
<div>
</div>
</form>
</body>
</html>

(The code-behind...)
public partial class Pages_RenderRep ort : System.Web.UI.P age
{
protected void Page_Load(objec t sender, EventArgs e)
{
if (!IsPostBack)
{
AddOnPreRenderC ompleteAsync(ne w
BeginEventHandl er(BeginAsyncOp eration), new
EndEventHandler (EndAsyncOperat ion));
}
}

private System.IAsyncRe sult BeginAsyncOpera tion(object sender, EventArgs
e, AsyncCallback cb, object state)
{
// ...

// Connect to Reporting Services
ReportingExecut ion.ReportExecu tionService rs = new
ReportingExecut ion.ReportExecu tionService();
rs.Credentials =
System.Net.Cred entialCache.Def aultCredentials ;

// 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;
ReportingExecut ion.Warning[] warnings = null;
string[] streamIDs = null;

// ...

try
{
// Set all the Reporting Services variables and
parameters and render the report
ReportingExecut ion.ExecutionIn fo execInfo = new
ReportingExecut ion.ExecutionIn fo();
ReportingExecut ion.ExecutionHe ader execHeader = new
ReportingExecut ion.ExecutionHe ader();
rs.ExecutionHea derValue = execHeader;
execInfo = rs.LoadReport(r eportPath1, historyID);
rs.SetExecution Parameters(para meters, "en-us");
System.String SessionId =
rs.ExecutionHea derValue.Execut ionID;
result = rs.Render(forma t, devInfo, out extension, out
mimeType, out encoding, out warnings, out streamIDs);
execInfo = rs.GetExecution Info();

// Force the render out of the report to the browser
Response.Clear( );
Response.ClearC ontent();
Response.ClearH eaders();
Response.Append Header("content-length",
result.Length.T oString());

switch (outputformat)
{
case "EXCEL":
Response.Conten tType =
"applicatio n/vnd.ms-excel"; // Seems to work
break;
case "MHTML":
Response.Conten tType = "message/rfc822";
break;
case "PDF":
Response.Conten tType = "applicatio n/pdf";
break;
default:
Response.Conten tType = "applicatio n/pdf";
break;
}

Response.Binary Write(result);
Response.Flush( );
Response.Close( );
Response.End();
}
catch (System.Excepti on ex)
{
// An exception occurred while trying to generate and
render the report
}
// Just needed to get a IAsyncResult to return
System.Net.WebR equest hwr =
System.Net.WebR equest.Create(" http://localhost/");
return hwr.BeginGetRes ponse(cb, state);
}

private void EndAsyncOperati on(System.IAsyn cResult ar)
{
//
}

"Steven Cheng[MSFT]" <st*****@online .microsoft.comw rote in message
news:lo******** ******@TK2MSFTN GHUB02.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.comw rote in message
news:zn******** ******@TK2MSFTN GHUB02.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.comw rote in message
news:T0******** ******@TK2MSFTN GHUB02.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

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

Similar topics

11
4634
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 serves as splash screen with the disclaimer of the application is shown. now the problem i am running into is in the display of the disclaimer which is really two page long and it should be formatted too. using a textbox seems not
5
2278
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 checking on the page_load event like if session("uid")="" then response.redirect("loginverify.aspx?er=nlog") elseif session("priv")<>0 then response.redirect("loginverify.aspx?er=nsad")
0
1250
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) and post it to the ASP.Net page from a client app Display the page to the user and allow them to add comments, change shipping info, etc... Allow the user to submit the order from the ASP.Net page
11
2737
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 things to browse web pages (not everyone). I don't know anything about this browser nor about media server implentation (on the pc side). I want to browse a page with Tv schedule (a simplified version of EuroTV.com). To do that, I've created a php...
1
1505
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 then redisplay the page again. What do I do in the first post back so the page is displayed to the user, but I then get a post back again? --
1
2120
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 help. Can anyone point me in the right direction? I haven't really found a good way to do it.
3
1954
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 displayed (I put a max limitation of 500 lines). Ex. list of cars Fiat to buy in UK. A clic on a line will bring me to the display page disp.php Ex. I will clic on the car n° 5 =<a href="disp.php?
1
1652
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
1348
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: http://172.16.32.54/creditformapp/default.aspx I just get source displayed and not the page. How do I actually get the web site to work?
0
2761
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 6.2.2 - i.e. my Server and 1 Windows XP as my client. The Server which is Windows 2K has 2 NICs on it, One is connected to the Modem - Gilat Satellite, and the other is connected to Cnet 8 port Switch with a default IP Address 192.168.0.1 and my...
0
8732
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9221
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9082
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8933
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6567
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5904
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4410
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4661
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3102
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 we have to send another system

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.