This is a migrated thread and some comments may be shown as answers.

Return false from OnResponseEnd event handler

3 Answers 73 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Laura
Top achievements
Rank 1
Laura asked on 23 Jun 2011, 09:31 PM
I'm trying to find out how to keep a page from posting back in an OnResponseEnd event handler.  The following is my code for the event hanlder:

 

 

 

 

//event called after server code executes
        function ResponseEnd(sender, args) {
            var hid = document.getElementById("<%=hidReturn.ClientID %>"); //get value from hidden control which is set by server code
            if (hid.value == "True") {
                alert("You don't have all the required documents");
                return false;
            }
            else
                return true;
        }
I see the alert box when the condition is met, but the return false statement does not prevent the page from continuing to process server-side code.  I want it to stop right there-- any suggestions?

3 Answers, 1 is accepted

Sort by
0
Radoslav
Telerik team
answered on 24 Jun 2011, 10:20 AM
Hi Christopher,

Could you please try using the OnRequestStart event instead of OnResponseEnd and let me know if the issue still persists? Additionally the similar approach is used for client confirmation and AJAX.

Looking forward for your reply.

All the best,
Radoslav
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Laura
Top achievements
Rank 1
answered on 24 Jun 2011, 01:53 PM
Radoslav:
Thank you for your reply.  I should have made my situation clearer.  The flow is something like this:
1.  User initiates Javascript request by clicking link button on a radgrid.
2.  Javascript calls the the ajaxRequest request method of AjaxManager.
3.  Server Side code executes and populates hidden field. This step is needed and provides validation for user.
4.  ResponseEnd event handler executes (the code I provided with my origianl post).

So you see, I need to call the server side code as specified in all scenarios as in step 3 above.  I need to stop the process after step 4 after the user clicks ok on the alter popup.  What happens now is that there is code that is executed on the server AFTER the return false statement in the ResponseEnd event handler.  This server side code is the ItemCommand event handler of the grid.  So using the OnRequestStart event that you suggested won't solve my problem.

Thanks
0
Radoslav
Telerik team
answered on 29 Jun 2011, 07:55 AM
Hi Christopher,

I am not sure I completely understand your scenario. The ResponseEnd event is fired when all data is transferred from the server and it could not be canceled. If a new request from client to the server is performed the RequestStart event is fired and it could be canceled. Could you please post your aspx markup with the related code behind. Thus we will be able to gather more details about your scenario and if is possible provide you a solution.

Looking forward for your reply.

Regards,
Radoslav
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
Ajax
Asked by
Laura
Top achievements
Rank 1
Answers by
Radoslav
Telerik team
Laura
Top achievements
Rank 1
Share this question
or