0

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();
//            }
 
        }
1
Contributor
1
Reply
2
Views
7 Years
Discussion Span
Last Post by virang_21
0

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 .

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.