skip to Main Content

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


  1. Ok, well the starting process or say even a nice gif like this:

    enter image description here

    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:

            <asp:Button ID="cmdProcess" runat="server" Text="Big process" 
                CssClass="btn"
                OnClick="cmdProcess_Click"
                OnClientClick="showwait()" />
    
            <script>
                function showwait() {
                    $("#MyProgress").show()
                }
            </script>
    
            <div id="MyProgress" style="display:none">
                <h2>Working</h2>
                <img src="../Content/wait2.gif" style="height: 67px; width: 80px" />
            </div>
    

    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:

        protected void cmdProcess_Click(object sender, EventArgs e)
        {
            Thread.Sleep(4000);
        }
    

    So, you have this:

    enter image description here

    When you click the button, then you would see this say for 4 seconds:

    enter image description here

    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.

    Login or Signup to reply.
  2. 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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search