Click here to Skip to main content
15,888,113 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am trying to do a very simple task, to show a pop-up in my application which says
"Please wait..We are Processing your Request..." or "Loading... ", whenever an user clicks on a button and after processing his request, the pop-up should disappear.
But the important thing is i don't want to use update panel to achieve this.

I have gone through many sites for solutions, and i got the below related solutions so far.

1. By using some ajax controls like update panel, update progress and modal pop extender and some javascript which gets the instances of when the request begun and when it ended, hence showing a pop-up between the range, which is what i was looking for. But the problem came when i got to know that it only handles the asynchronus requests, not the synchronus requests.

2. Some jquery functions(SetTimeOut), which will show a pop-up menu for a few seconds(even the time limit is defined while scripting), and disappears after the time limit. Again, this is far from what i have been looking for. This will have no clue, when exactly the processing of request has been completed!

So i wanted to have the same functionality of what the above FIRST method does, but for a normal synchronus postback, so that i can use it wherever i need, without touching update panel.

Below is the javascript code for FirstMethod.(Just to provide more info about my first point)

C#
 var prm = Sys.WebForms.PageRequestManager.getInstance();
        
//Raised before processing of an asynchronous postback
      prm.add_beginRequest(BeginRequestHandler);

        //Raised after an asynchronous postback is finished 
 prm.add_endRequest(EndRequestHandler);
 
       function BeginRequestHandler(sender, args) {
            //Shows the modal popup - the update progress
            var popup = $find('<%= modalPopup.ClientID %>');
            if (popup != null) {
                popup.show();


            }
        }

        function EndRequestHandler(sender, args) {
            //Hide the modal popup - the update progress
            var popup = $find('<%= modalPopup.ClientID %>');
            if (popup != null) {
                popup.hide();

            }
        }
Posted
Updated 13-Dec-13 1:27am
v6
Comments
Mitchell J. 13-Dec-13 6:11am    
How is the client browser supposed to receive information about how the task is going?
Prathap S V 13-Dec-13 6:31am    
@Craig even i am not sure how it is supposed to recieve., and i didn't mean to use the same javascript method to achieve this, any alternate methods also be helpful.
Though i can say,Sys.WebForms.PageRequestManager is able to get the information about when the task has been started and ended for all the controls which are inside update panel.
Mitchell J. 13-Dec-13 6:39am    
Then I suppose you should use a non-progressive indicator, like rotating dots or a marquee style progress bar :-)
Prathap S V 13-Dec-13 6:45am    
@Craig Yes. that will do, but i don't know any methods that tracks and displays a loading gif image/rotating dots ,whenever a synchronus postback request is sent to server(to display that loading image during start and end of a event/request). that is what i have been looking for.
Mitchell J. 13-Dec-13 6:51am    
Ahh... now I understand. You can't find a way to trigger events for the synchronous operations? Do you call the synchronous operations in your own code?

1 solution

Is this what you are after?

Imagine you have a form like this...
HTML
<form>
    <input type="text" id="box1" />
    <input type="text" id="box2" />
    <input type="submit" id="btn_submit" />
</form>

Now, with jQuery...
JavaScript
$(document).ready(function () {
   $('#btn_submit').click(function (event) {
      //Display the popup using the same or similar visuals as in the asynchronous operations.
   });
});

Now I'm not sure - does the DOM refresh when the server responds? If it does, you don't need to worry about cancelling the progress animation.

If it doesn't you could watch with a javscript loop every few seconds for the DOM changes to occur, and then remove the animation.

Hopefully this helps :-)
 
Share this answer
 
Comments
Prathap S V 13-Dec-13 7:23am    
@Craig, sounds good, but even i don't hope DOM to refresh when the server responds, but as you suggested may be i should track DOM changes and close the animation. Let me try and get back to you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900