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

ajax call on window.onbeforeunload

1 Answer 199 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Kash
Top achievements
Rank 1
Kash asked on 13 Oct 2011, 02:45 PM
I want to save records if use navigates to other pages I am using general ajax request onbeforeunload.
but it gives me following error

  1. Uncaught Sys.WebForms.PageRequestManagerServerErrorException: Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 0
Sys.WebForms.PageRequestManager._endPostBack
Sys.WebForms.PageRequestManager._onFormSubmitCompleted
(anonymous function)
(anonymous function)
Sys.Net.WebRequest.completed
_onReadyStateChange
Telerik.Web.UI.WeResource.axd:15

I am using following script

<script language="JavaScript1.2" type="text/javascript">
window.onbeforeunload = function() { $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest(''); }
</script>

ASPX Code:
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" 
        onajaxrequest="RadAjaxManager1_AjaxRequest">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="divInterviewEvents">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="divInterviewEvents" LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>

Code Behind:
protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)
        {
            this.SaveRecord();
        }

1 Answer, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 18 Oct 2011, 08:19 AM
Hi Muhammad,

I tried to replicate the described issue locally but to no avail. Please find attached a sample runnable application which works correctly on my side. test it locally and verify what the difference in your case is. Also please test your application by using regular asp UpdatePanel and verify if the issue still persists.

Regards,
Maria Ilieva
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
Ajax
Asked by
Kash
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
Share this question
or