Is it possible to do a page postback after endREquest() or in the endRequest() ?

I have a button in update panel that I allow user to click just once as the process took bit of time to finish. I used following code to achieve that but now my application needs to do postback after the request is over. I tried Response.Redirect() and Server.Transfer() but that didn't work may be because I am doing a asynchronous postback and request ends at endRequest(). Is it possible to do postback after that endRequest() or within that endRequest() ?

Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(startRequest);

        Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endRequest);

        function startRequest(sender, e) {

            //hide the update panel during the AJAX call
            var from = e.get_postBackElement();
            var btnId = '<%=btnStatusUpdate.ClientID %>';
            var btnSendId = '<%=btnSendAgain.ClientID %>';

            if (from.id == btnId) 
            {
            
             //document.getElementById('<%=btnStatusUpdate.ClientID%>').style.display = 'none';

            //disable search button during the AJAX call

                document.getElementById('<%=btnStatusUpdate.ClientID%>').value = "Please wait. Processing...";
                document.getElementById('<%=btnStatusUpdate.ClientID%>').disabled = true;
                
            }
           if(btnSendId == from.id)
           {
               document.getElementById('<%=btnSendAgain.ClientID%>').value = "Please wait. Sending...";
               document.getElementById('<%=btnSendAgain.ClientID%>').disabled = true;
               
           }

        }



        function endRequest(sender, e) {

            
            //show the update panel once the AJAX call has completed
              //hide the update panel during the AJAX call
//            var from = e.get_postBackElement();
//            var btnId = '<%=btnStatusUpdate.ClientID %>';
//            
//            if (from.id == btnId) {

            document.getElementById('<%=btnStatusUpdate.ClientID%>').value = "Update";
            document.getElementById('<%=btnStatusUpdate.ClientID%>').disabled = false;

            document.getElementById('<%=btnSendAgain.ClientID%>').value = "Send";
            document.getElementById('<%=btnSendAgain.ClientID%>').disabled = false;
           // }
            
//                var from = e.get_postBackElement();
//            var btnId = '<%=btnStatusUpdate.ClientID %>';
//            var btnSendId = '<%=btnSendAgain.ClientID %>';

//            if (from.id == btnId) {
//                document.getElementById('<%=Button1.ClientID%>').click();
//            }
 
        }

Issue resolved now.

I put a hidden button on the page and do page postback from its click event. So once I reach at the end of a Asynchronous postback I call button's click event like Button1_Click(null,null); from the button which is performing asynchronous postback and that does the trick for me to do the page postback .

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.