I’m creating a web form project in asp.net with file attachment.
I place a label control that would indicate the progress of the process
(e.g. ‘Starting process’, few seconds change to ‘Reading 1st record file’, final label ‘File process complete!’).
How can i achieve this routine? Would that need a page refresh?
Looking forward to your response. Thank you.
2
Answers
Ok, well the starting process or say even a nice gif like this:
So, the FIRST message, or animation is no problem.
Additional messages? Hum, that’s MUCH more difficult unless you fake this.
So, for a simple example, lets say we have a button that takes a long time (say 4 seconds).
So, we have say this button:
So, when you click the above button, it will run BOTH a client side routine (that shows our div), and then the server side code, say this:
So, you have this:
When you click the button, then you would see this say for 4 seconds:
So, this is easy, since we just display that div.
And bonus? Well, since the button is a post-back, then when the button code is done then of course client side will re-fresh, and now our "delay div" does not display anymore.
However, if you wanted say the message to change, say like :
Working part 1 …….
Then Working part 2 …..
Then I would start that "long" process as a web method. This can be difficult, since any web method you call does NOT have use of all the page controls.
often, you can (could) on the post back, fire off a new thread, and pass values, and then have a timer (client side) that calls a web method that returns the status.
And that timer would have to "check" some status value (say every one second), and get some value from the server. Since we don’t have (and really can’t have) additonal post-backs, then that web method will have to get that status message. That web method will have to return some status PROBABLY from session().
So display of "one" message when you click a button?
Very easy.
The progress of the upload process can be achieved using the ajax upload instead of the regular upload. You need to create a web service which will accept the file as input and then post to it. Once completed then you can hide the progress bar.
Some solutions are:
File upload progress bar with jQuery
Upload Progress Bar in PHP