Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Progressbar at runtime in asp.net

Status
Not open for further replies.

cyberdeminout

Programmer
Jul 19, 2005
37
US
Hi

Can anyone help me how to show progress bar at runtime in asp.net(language=vb).

Thanks in advance.

Ram
 
A progress bar to show what?


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
maybe its for file uploading???

Known is handfull, Unknown is worldfull
 
am importing records from excel to DB. and want to show progress bar to show status of importing.
 
hmm, intersting

in normal ASP we use the Response.Buffer() method and Response.Flush() method.

i guess u have to write this file using Classing ASP metod of coding ie <%%> method.


the working is something like this:

<%
dim i as integer
for i=0 to 10000
response.write(i & "<br>")
response.flush()
next
%>

if u notice even before the entire script is processed the output starts.

since normal .NET coding DOES not use response.write() i am assuming that u have to use classic asp method...

Known is handfull, Unknown is worldfull
 
Whether it is classic ASP or ASP.NET is irrelevant.

If you perform your inserts in stages, then you can return information to the page to say how much progress has been made. If you simply fire off an insert script you will have no way of knowing how much progress has been made and you only option is to inform the user that something is happenign, but you can't tell them how much or how long it will take.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
>>Whether it is classic ASP or ASP.NET is irrelevant

is there a way to do this in .NET itself?


>> If you simply fire off an insert script you will have no way of knowing how much progress has been made and you only option is to inform the user that something is happenign

fair point, but if the operation is huge u could flushout every 15th loop or something like that. then using javascript u could show a progress bar (the output by .NET will be a javascript variable). thats what i do...

Known is handfull, Unknown is worldfull
 
is there a way to do this in .NET itself?
Yes there is and there are a number of different solutions in how to acheive it (i.e. client callbacks).

fair point, but if the operation is huge u could flushout every 15th loop or something like that. then using javascript u could show a progress bar (the output by .NET will be a javascript variable). thats what i do...
That's fair enough, and is what I suggested as part of my second point. You are showing the user that something is happening but what you are not able to show them is how long is left. For example, even though you write out data every 15th loop, the user doesn't know if there are 2 or 2000 more loops to go. Rather than making the server work for each iteration, you could also display a simple animated gif of a progress bar that would have the same effect.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
>>For example, even though you write out data every 15th loop, the user doesn't know if there are 2 or 2000 more loops to go.

nope, u CAN actually show a progress bar. the programmer knows howm many lops are going to excute right? he will convert that on a percentage basis and send it to a JS variable. another variable will hold just an updated value so a REAL time progress bar is possible.

e.g:

page_load
u know the number of records there fore we output a js variable called EntireRows(lets say it is equal to 1000) and flush it.

for 15th each loop u fulsh out another JS variable called CurrentStatus.

in javascript u write a function that takes 2 args: one CurrentStatus another EntireRows and builds a progress bar based on that.

u simply flush a call to the function every 15th loop.

therefore updating the progress bar at the same time...

Known is handfull, Unknown is worldfull
 
the programmer knows howm many lops are going to excute right?
Not necessarily. If you have an insert script you may not know how many records were due to be inserted unless you ran the select query first to find out, and then run the insert after that.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
yes, a simple count query ought to give that for u. i am not saying its straight forward! i am just saying it IS possible to show a real time progress bar...

Known is handfull, Unknown is worldfull
 
I'm not denying that it is possible, hence my statement about client callbacks (an article on this is available at
It certainly wouldn't be efficient, in the above scenario, to run a select statement and then the insert statement just to find out the number of records to return. For example, what if the select statement took 10 minutes to run? Wouldn't that need a progress bar as well?!


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.
 
>>what if the select statement took 10 minutes to run?

why would a count stmt take 10 mins to run? i dont get the scenario.


the example that u show uses AJAX (XMLHTTP), i dont think u could give a real time bar there, just an animation...

Known is handfull, Unknown is worldfull
 
why would a count stmt take 10 mins to run?
OK, 10 minutes may have been a slight exaggeration but it was just to illustrate the point. A count statement isn't necessarily quick though - it obviously depends on a lot of things; table size, indexes, joins etc. What I was trying to show was, that if it took 20 minutes to do the insert, it may take 10 minutes to get the count and therefore it wouldn't be an efficient approach to wait 10 mintues to get the count just so you could inform the user that they were x percent through the 20 mintute insert query.

the example that u show uses AJAX (XMLHTTP), i dont think u could give a real time bar there, just an animation...
I'm not sure I understand your thinking here. The idea of XMLHTTP is that you can return values to the page, without having to refresh the whole page. So, using XMLHTTP, you can return a status at various intervals to the page, to show what progress has been made (therefore it is pretty much in real-time).


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
>>The idea of XMLHTTP is that you can return values to the page, without having to refresh the whole page. So, using XMLHTTP, you can return a status at various intervals to the page, to show what progress has been made


this is the function i found in that link:

xmlhttp.Open("POST", url, true);

// Register a callback for the call
xmlhttp.onreadystatechange =
function ()
{
if (xmlhttp.readyState == 4)
{
var response = xmlhttp.responseText;
divResponse.innerHTML += "<p>" + response + "</p>";

stopProgressBar();
}
}

// Send the actual request
xmlhttp.Send();

in XMLHTTP u have to wait for the requested page to execute entirely before javscript can act upon it. therefore the script can 'entertain' the users. it cannot show figures like 35%, 45%,50%,75% etc...

Known is handfull, Unknown is worldfull
 
OK, I see where you are coming from. That article does just "entertain" the user by showing a progress bar but I didn't mean that you could use that article exactly to do what I was describing. What I meant was that article explains the principles of XMLHTTP, and using those principles, you could " return a status at various intervals to the page, to show what progress has been made". Sorry for the confusion!


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
>>" return a status at various intervals to the page, to show what progress has been made"

do u mean 50%,75% etc type? or do u meant that one pagce can contact how many every ASPX files that it wants to?

there is one more problem in XMLHTTP, u cannot have user validation coding(like forms authentication).
it is well suited for web services (as rightly pointed out by the article)...

Known is handfull, Unknown is worldfull
 
vbkris
then using javascript u could show a progress bar (the output by .NET will be a javascript variable). thats what i do...
can you post the code. Just use a thread.sleep to emulate a long running process. I am curious to see the javascript, and how the codebehind updates the javascript variable to indicate progress.
Thank you very much,
Marty
 
sure will do, give me some time...



Known is handfull, Unknown is worldfull
 
do u mean 50%,75% etc type?
Basically yes, I mean that you can return a status that could be a percentage or it could be a status that simply says something like "Part 1 has finished" etc.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top