473,387 Members | 1,545 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

File Upload Progress

Hi,
I have a page that uploads files to my server and I wish to display a
"Please wait while uploading" page to the user while the file is uploading.
I have been able to redirect the user once the file is finished uploading
but am not sure how to do it while file is uploading.
Some sample code would be welcomed with open arms.

Thank You.
Nov 17 '05 #1
4 5699
This is about the best solution given by brad mcCabe in his article
aspnetpro.com

UI Tip

LANGUAGES: VB .NET

ASP.NET VERSIONS: 1.0 | 1.1
Make a Progress Indicator For Slow-Loading Pages

Create a pop-up status page that lets your users know they're not
forgotten.
By Brad McCabe
One problem with ASP.NET is that keeping the user informed about the
status of a long running task is difficult. When a page that takes time to
load is posted to the server, the user often is left wondering whether the
application is responding or if their request even made it to the server.
I'll give you a simple tip that provides the user a basic status screen to
provide them better feedback.

First, create a basic page that asks a user for their name and
provides them a button to submit the page. The code behind the button is
pretty simple:

Response.Redirect("EndPage.aspx?name=" & Name.Text)

Next, create a simple page that sleeps the thread for 10 seconds to
simulate a long running process. After the thread wakes up, the page updates
a label to welcome the user. The code looks like this:
System.Threading.Thread.Sleep(10000)

Label1.Text = "Welcome " & Request.QueryString("Name") & "!"
If you run these two pages, you'll find that when you click on the
submit button, the browser sits on the start page for 10 seconds without any
feedback to the user. Now modify the start-page code to redirect to an
intermediary loading page. This page provides your end user with visual
notification that the application is processing their request. Here's the
new code behind on the submit button:

Dim URL As String = "EndPage.aspx?name=" & Name.Text

Response.Redirect("Loading.Aspx?Page=" & URL)
The previous code now captures the original URL and passes it on the
query string to the loading page, Loading.Aspx. The loading page then
displays to the user a status message while loading the requested page.
First, start by creating a basic message for your user:
<table border="0" cellpadding="0" cellspacing="0"

width="99%" height="99%" align="center"

valign="middle">

<tr>

<td align="center" valign="middle">

<font color="Red" size="5">
<span id="Message">Loading&nbsp;--

Please Wait</span>

<span id="Progress" style="WIDTH:25px;

TEXT-ALIGN:left"></span>

</font>

</td>

</tr>

</table>
Inside the table at the middle of the screen, you want to display a
message to the user. You'll use JavaScript's Progress span tag here to
update the screen and inform the user that the application is responding.
Now that the screen is set up, you need to hook up the JavaScript to
make the page work using the client-side onLoad and onUnload events:
<body onload="BeginPageLoad()" onunload="EndPageLoad()">
When the page is loaded, your custom BeginPageLoad function is fired.
BeginPageLoad has two lines of javascript:
location.href = "<%= Request.QueryString("Page")%>";

iIntervalId = window.setInterval("iLoopCounter=

UpdateProgress(iLoopCounter, iMaxLoop)", 500);
The first line of code starts the loading processes for the requested
page. After the page has been requested from the server, a call to the
UpdateProgress function starts a timer that updates the screen. This
function uses the Progress span tag and displays five dots in succession.
When the fifth dot is added, the span is cleared and the process starts
over. Once the new page is finished loading, it is rendered immediately for
the user and the EndPageLoad function will be processed. The EndPageLoad
function then performs some basic clean-up and notifies the user if the
transfer fails or an error occurs:
window.clearInterval(iIntervalId);

Progress.innerText = "Page Loaded -- Not Transferring";
As you can see, you need only a few lines of JavaScript to provide the
user with visual notification that their request has been submitted and is
being processed. By providing the user with this feedback, you can help
eliminate the possibility that the user will cancel the page request and
attempt to resubmit the page or hit the submit button repeatedly, possibly
corrupting your data or bringing down the application.
Got a UI question, tip, or idea for a topic you'd like me to cover?
I'd love to hear it. E-mail me at mailto:ui****@aspnetPRO.com.
This article's sample code is available for download.
Brad McCabe is the technical evangelist for Infragistics. Brad also
has been a systems architect and consultant for Verizon Communications and
many other clients, and he was a leading .NET evangelist within Ajilon
Consulting. His primary interests include ASP.NET, Windows CE .NET, .NET
Compact Framework, and Microsoft's networking technologies. E-mail him at
mailto:ui****@aspnetPRO.com.
"Kenneth Keeley" <ke*******@hotmail.com.nowhere> wrote in message
news:OP**************@TK2MSFTNGP12.phx.gbl...
Hi,
I have a page that uploads files to my server and I wish to display a
"Please wait while uploading" page to the user while the file is uploading. I have been able to redirect the user once the file is finished uploading
but am not sure how to do it while file is uploading.
Some sample code would be welcomed with open arms.

Thank You.

Nov 17 '05 #2
This is about the best solution given by brad mcCabe in his article
aspnetpro.com

UI Tip

LANGUAGES: VB .NET

ASP.NET VERSIONS: 1.0 | 1.1
Make a Progress Indicator For Slow-Loading Pages

Create a pop-up status page that lets your users know they're not
forgotten.
By Brad McCabe
One problem with ASP.NET is that keeping the user informed about the
status of a long running task is difficult. When a page that takes time to
load is posted to the server, the user often is left wondering whether the
application is responding or if their request even made it to the server.
I'll give you a simple tip that provides the user a basic status screen to
provide them better feedback.

First, create a basic page that asks a user for their name and
provides them a button to submit the page. The code behind the button is
pretty simple:

Response.Redirect("EndPage.aspx?name=" & Name.Text)

Next, create a simple page that sleeps the thread for 10 seconds to
simulate a long running process. After the thread wakes up, the page updates
a label to welcome the user. The code looks like this:
System.Threading.Thread.Sleep(10000)

Label1.Text = "Welcome " & Request.QueryString("Name") & "!"
If you run these two pages, you'll find that when you click on the
submit button, the browser sits on the start page for 10 seconds without any
feedback to the user. Now modify the start-page code to redirect to an
intermediary loading page. This page provides your end user with visual
notification that the application is processing their request. Here's the
new code behind on the submit button:

Dim URL As String = "EndPage.aspx?name=" & Name.Text

Response.Redirect("Loading.Aspx?Page=" & URL)
The previous code now captures the original URL and passes it on the
query string to the loading page, Loading.Aspx. The loading page then
displays to the user a status message while loading the requested page.
First, start by creating a basic message for your user:
<table border="0" cellpadding="0" cellspacing="0"

width="99%" height="99%" align="center"

valign="middle">

<tr>

<td align="center" valign="middle">

<font color="Red" size="5">
<span id="Message">Loading&nbsp;--

Please Wait</span>

<span id="Progress" style="WIDTH:25px;

TEXT-ALIGN:left"></span>

</font>

</td>

</tr>

</table>
Inside the table at the middle of the screen, you want to display a
message to the user. You'll use JavaScript's Progress span tag here to
update the screen and inform the user that the application is responding.
Now that the screen is set up, you need to hook up the JavaScript to
make the page work using the client-side onLoad and onUnload events:
<body onload="BeginPageLoad()" onunload="EndPageLoad()">
When the page is loaded, your custom BeginPageLoad function is fired.
BeginPageLoad has two lines of javascript:
location.href = "<%= Request.QueryString("Page")%>";

iIntervalId = window.setInterval("iLoopCounter=

UpdateProgress(iLoopCounter, iMaxLoop)", 500);
The first line of code starts the loading processes for the requested
page. After the page has been requested from the server, a call to the
UpdateProgress function starts a timer that updates the screen. This
function uses the Progress span tag and displays five dots in succession.
When the fifth dot is added, the span is cleared and the process starts
over. Once the new page is finished loading, it is rendered immediately for
the user and the EndPageLoad function will be processed. The EndPageLoad
function then performs some basic clean-up and notifies the user if the
transfer fails or an error occurs:
window.clearInterval(iIntervalId);

Progress.innerText = "Page Loaded -- Not Transferring";
As you can see, you need only a few lines of JavaScript to provide the
user with visual notification that their request has been submitted and is
being processed. By providing the user with this feedback, you can help
eliminate the possibility that the user will cancel the page request and
attempt to resubmit the page or hit the submit button repeatedly, possibly
corrupting your data or bringing down the application.
Got a UI question, tip, or idea for a topic you'd like me to cover?
I'd love to hear it. E-mail me at mailto:ui****@aspnetPRO.com.
This article's sample code is available for download.
Brad McCabe is the technical evangelist for Infragistics. Brad also
has been a systems architect and consultant for Verizon Communications and
many other clients, and he was a leading .NET evangelist within Ajilon
Consulting. His primary interests include ASP.NET, Windows CE .NET, .NET
Compact Framework, and Microsoft's networking technologies. E-mail him at
mailto:ui****@aspnetPRO.com.
"Kenneth Keeley" <ke*******@hotmail.com.nowhere> wrote in message
news:OP**************@TK2MSFTNGP12.phx.gbl...
Hi,
I have a page that uploads files to my server and I wish to display a
"Please wait while uploading" page to the user while the file is uploading. I have been able to redirect the user once the file is finished uploading
but am not sure how to do it while file is uploading.
Some sample code would be welcomed with open arms.

Thank You.

Nov 17 '05 #3
This doesn't seem to help when uploading Large Files as the
Response.Redirect does not happen until after the file is uploaded.

"Rajesh.V" <Ra***********@hotmail.com> wrote in message
news:OD**************@TK2MSFTNGP11.phx.gbl...
This is about the best solution given by brad mcCabe in his article
aspnetpro.com

UI Tip

LANGUAGES: VB .NET

ASP.NET VERSIONS: 1.0 | 1.1
Make a Progress Indicator For Slow-Loading Pages

Create a pop-up status page that lets your users know they're not
forgotten.
By Brad McCabe
One problem with ASP.NET is that keeping the user informed about the
status of a long running task is difficult. When a page that takes time to
load is posted to the server, the user often is left wondering whether the
application is responding or if their request even made it to the server.
I'll give you a simple tip that provides the user a basic status screen to
provide them better feedback.

First, create a basic page that asks a user for their name and
provides them a button to submit the page. The code behind the button is
pretty simple:

Response.Redirect("EndPage.aspx?name=" & Name.Text)

Next, create a simple page that sleeps the thread for 10 seconds to
simulate a long running process. After the thread wakes up, the page updates a label to welcome the user. The code looks like this:
System.Threading.Thread.Sleep(10000)

Label1.Text = "Welcome " & Request.QueryString("Name") & "!"
If you run these two pages, you'll find that when you click on the
submit button, the browser sits on the start page for 10 seconds without any feedback to the user. Now modify the start-page code to redirect to an
intermediary loading page. This page provides your end user with visual
notification that the application is processing their request. Here's the
new code behind on the submit button:

Dim URL As String = "EndPage.aspx?name=" & Name.Text

Response.Redirect("Loading.Aspx?Page=" & URL)
The previous code now captures the original URL and passes it on the
query string to the loading page, Loading.Aspx. The loading page then
displays to the user a status message while loading the requested page.
First, start by creating a basic message for your user:
<table border="0" cellpadding="0" cellspacing="0"

width="99%" height="99%" align="center"

valign="middle">

<tr>

<td align="center" valign="middle">

<font color="Red" size="5">
<span id="Message">Loading&nbsp;--

Please Wait</span>

<span id="Progress" style="WIDTH:25px;

TEXT-ALIGN:left"></span>

</font>

</td>

</tr>

</table>
Inside the table at the middle of the screen, you want to display a
message to the user. You'll use JavaScript's Progress span tag here to
update the screen and inform the user that the application is responding.
Now that the screen is set up, you need to hook up the JavaScript to
make the page work using the client-side onLoad and onUnload events:
<body onload="BeginPageLoad()" onunload="EndPageLoad()">
When the page is loaded, your custom BeginPageLoad function is fired. BeginPageLoad has two lines of javascript:
location.href = "<%= Request.QueryString("Page")%>";

iIntervalId = window.setInterval("iLoopCounter=

UpdateProgress(iLoopCounter, iMaxLoop)", 500);
The first line of code starts the loading processes for the requested page. After the page has been requested from the server, a call to the
UpdateProgress function starts a timer that updates the screen. This
function uses the Progress span tag and displays five dots in succession.
When the fifth dot is added, the span is cleared and the process starts
over. Once the new page is finished loading, it is rendered immediately for the user and the EndPageLoad function will be processed. The EndPageLoad
function then performs some basic clean-up and notifies the user if the
transfer fails or an error occurs:
window.clearInterval(iIntervalId);

Progress.innerText = "Page Loaded -- Not Transferring";
As you can see, you need only a few lines of JavaScript to provide the user with visual notification that their request has been submitted and is
being processed. By providing the user with this feedback, you can help
eliminate the possibility that the user will cancel the page request and
attempt to resubmit the page or hit the submit button repeatedly, possibly
corrupting your data or bringing down the application.
Got a UI question, tip, or idea for a topic you'd like me to cover?
I'd love to hear it. E-mail me at mailto:ui****@aspnetPRO.com.
This article's sample code is available for download.
Brad McCabe is the technical evangelist for Infragistics. Brad also
has been a systems architect and consultant for Verizon Communications and
many other clients, and he was a leading .NET evangelist within Ajilon
Consulting. His primary interests include ASP.NET, Windows CE .NET, .NET
Compact Framework, and Microsoft's networking technologies. E-mail him at
mailto:ui****@aspnetPRO.com.
"Kenneth Keeley" <ke*******@hotmail.com.nowhere> wrote in message
news:OP**************@TK2MSFTNGP12.phx.gbl...
Hi,
I have a page that uploads files to my server and I wish to display a
"Please wait while uploading" page to the user while the file is

uploading.
I have been able to redirect the user once the file is finished uploading but am not sure how to do it while file is uploading.
Some sample code would be welcomed with open arms.

Thank You.


Nov 17 '05 #4
This doesn't seem to help when uploading Large Files as the
Response.Redirect does not happen until after the file is uploaded.

"Rajesh.V" <Ra***********@hotmail.com> wrote in message
news:OD**************@TK2MSFTNGP11.phx.gbl...
This is about the best solution given by brad mcCabe in his article
aspnetpro.com

UI Tip

LANGUAGES: VB .NET

ASP.NET VERSIONS: 1.0 | 1.1
Make a Progress Indicator For Slow-Loading Pages

Create a pop-up status page that lets your users know they're not
forgotten.
By Brad McCabe
One problem with ASP.NET is that keeping the user informed about the
status of a long running task is difficult. When a page that takes time to
load is posted to the server, the user often is left wondering whether the
application is responding or if their request even made it to the server.
I'll give you a simple tip that provides the user a basic status screen to
provide them better feedback.

First, create a basic page that asks a user for their name and
provides them a button to submit the page. The code behind the button is
pretty simple:

Response.Redirect("EndPage.aspx?name=" & Name.Text)

Next, create a simple page that sleeps the thread for 10 seconds to
simulate a long running process. After the thread wakes up, the page updates a label to welcome the user. The code looks like this:
System.Threading.Thread.Sleep(10000)

Label1.Text = "Welcome " & Request.QueryString("Name") & "!"
If you run these two pages, you'll find that when you click on the
submit button, the browser sits on the start page for 10 seconds without any feedback to the user. Now modify the start-page code to redirect to an
intermediary loading page. This page provides your end user with visual
notification that the application is processing their request. Here's the
new code behind on the submit button:

Dim URL As String = "EndPage.aspx?name=" & Name.Text

Response.Redirect("Loading.Aspx?Page=" & URL)
The previous code now captures the original URL and passes it on the
query string to the loading page, Loading.Aspx. The loading page then
displays to the user a status message while loading the requested page.
First, start by creating a basic message for your user:
<table border="0" cellpadding="0" cellspacing="0"

width="99%" height="99%" align="center"

valign="middle">

<tr>

<td align="center" valign="middle">

<font color="Red" size="5">
<span id="Message">Loading&nbsp;--

Please Wait</span>

<span id="Progress" style="WIDTH:25px;

TEXT-ALIGN:left"></span>

</font>

</td>

</tr>

</table>
Inside the table at the middle of the screen, you want to display a
message to the user. You'll use JavaScript's Progress span tag here to
update the screen and inform the user that the application is responding.
Now that the screen is set up, you need to hook up the JavaScript to
make the page work using the client-side onLoad and onUnload events:
<body onload="BeginPageLoad()" onunload="EndPageLoad()">
When the page is loaded, your custom BeginPageLoad function is fired. BeginPageLoad has two lines of javascript:
location.href = "<%= Request.QueryString("Page")%>";

iIntervalId = window.setInterval("iLoopCounter=

UpdateProgress(iLoopCounter, iMaxLoop)", 500);
The first line of code starts the loading processes for the requested page. After the page has been requested from the server, a call to the
UpdateProgress function starts a timer that updates the screen. This
function uses the Progress span tag and displays five dots in succession.
When the fifth dot is added, the span is cleared and the process starts
over. Once the new page is finished loading, it is rendered immediately for the user and the EndPageLoad function will be processed. The EndPageLoad
function then performs some basic clean-up and notifies the user if the
transfer fails or an error occurs:
window.clearInterval(iIntervalId);

Progress.innerText = "Page Loaded -- Not Transferring";
As you can see, you need only a few lines of JavaScript to provide the user with visual notification that their request has been submitted and is
being processed. By providing the user with this feedback, you can help
eliminate the possibility that the user will cancel the page request and
attempt to resubmit the page or hit the submit button repeatedly, possibly
corrupting your data or bringing down the application.
Got a UI question, tip, or idea for a topic you'd like me to cover?
I'd love to hear it. E-mail me at mailto:ui****@aspnetPRO.com.
This article's sample code is available for download.
Brad McCabe is the technical evangelist for Infragistics. Brad also
has been a systems architect and consultant for Verizon Communications and
many other clients, and he was a leading .NET evangelist within Ajilon
Consulting. His primary interests include ASP.NET, Windows CE .NET, .NET
Compact Framework, and Microsoft's networking technologies. E-mail him at
mailto:ui****@aspnetPRO.com.
"Kenneth Keeley" <ke*******@hotmail.com.nowhere> wrote in message
news:OP**************@TK2MSFTNGP12.phx.gbl...
Hi,
I have a page that uploads files to my server and I wish to display a
"Please wait while uploading" page to the user while the file is

uploading.
I have been able to redirect the user once the file is finished uploading but am not sure how to do it while file is uploading.
Some sample code would be welcomed with open arms.

Thank You.


Nov 17 '05 #5

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

Similar topics

3
by: Gary O'Malley | last post by:
Everytime I download a file from the web I get a nice animated dialogue box that shows the size of the file, how much has been received and the approximate remaining time. It also gives the...
14
by: Todd Denlinger | last post by:
Ok, I know how to upload a file in asp.net using the <input type="file" runat="server"> control. What I don't know how to do is monitor the progress of the upload so that I can show the...
12
by: JMB | last post by:
Hello, I was wondering if anyone knew of any projects extending the inline upload progress bar to utilize an inpage image uploader with bar, without having to refresh or go to a seperate page,...
4
by: Pavils Jurjans | last post by:
Hello, I have the following setup: The page that contains the form with file upolad HTML control resides on another server that doesn't have ASP.NET available. It may well be just static...
6
by: Marko Vuksanovic | last post by:
I am trying to implement a file upload progress indicator (doesn't have to be a progress bar) using atlas... I do realize that the indicator cannot be implemented using Update panel control, but is...
5
by: LtCommander | last post by:
Hello all, 1. I am a little new to ASP.NET, so please bear with me. 2. I am trying to create a very simple website which requires an upload box (end user file sizes may be anywhere between 1MB...
3
by: markus.rietzler | last post by:
i want to do (multiple) file upload(s) and display a progress bar. with firefox and safari it is no problem at all. only IE makes some problems. my script is based on ajax-uploader, which can be...
4
by: AshishMishra16 | last post by:
HI friends, I am using the Flex to upload files to server. I m getting all the details about the file, but I m not able to upload it to Server. Here is the code i m using for both flex & for...
3
by: shapper | last post by:
Hello, I need to upload a file. Can I only do this with the File Upload control? I also need the following: - Send upload info, upload percentage, continuously to a JavaScript function so...
1
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...

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.