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

RadAjaxPanel not fire ResponseEnd and busybox stays on the Page.

1 Answer 153 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Nirnay Bansal
Top achievements
Rank 1
Nirnay Bansal asked on 29 Jul 2008, 06:54 PM
Hi,

Following is my code for Page1 and Page2.
Page 1 is having a button under RadAjaxPanel, on the click of the button, user redirect to Page2 which actually spits .xls file and close himself.
User found himself on the same page Page1, because Page2 only spits xls in binary.

Problem:
After I click on button1 on Page1, busybox starts and continue to display even after I click "Save, Open or Cancel" button of file Download Dialogbox.

R&D:
I did some research and found that ResponseEnd is not firing, after we close File Download Dialogbox.

Page1:

<%

@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<%

@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

<!

DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<

html xmlns="http://www.w3.org/1999/xhtml">

<

head runat="server">

<title>Untitled Page</title>

<script type="text/javascript">

function requestStart(sender, eventArgs)

{

alert(

'Start');

}

function responseEnd(sender, eventArgs)

{

alert(

'End');

}

</script>

</

head>

<

body>

<form id="form1" runat="server">

<asp:ScriptManager ID="ScriptManager1" runat="server">

</asp:ScriptManager>

<telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" SkinID="apDefault"

LoadingPanelID="LoadingPanel1" ClientEvents-OnRequestStart="requestStart"

ClientEvents-OnResponseEnd="responseEnd"

Width="100%">

<br />

<br />

<br />

<br />

<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click1"></asp:Button>

<br />

<br />

<br />

<br />

</telerik:RadAjaxPanel>

<telerik:RadAjaxLoadingPanel ID="LoadingPanel1" SkinID="lpDefault" runat="server">

<asp:Image ID="Image1" SkinID="imgLoading" runat="Server" />

</telerik:RadAjaxLoadingPanel>

</form>

</

body>

</

html>



Page1.aspx.cs

protected

void Button1_Click1(object sender, EventArgs e)

{

Response.Redirect(

"ExportSuccess.aspx");

}

================================PAGE2=======================

<%

@ Page Language="C#" AutoEventWireup="true" CodeFile="ExportSuccess.aspx.cs" Inherits="ExportSuccess" %>

 

<!

DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<

html xmlns="http://www.w3.org/1999/xhtml" >

<

head runat="server">

 

<title>Untitled Page</title>

</

head>

<

body>

 

<form id="form1" runat="server">

 

<div>

 

</div>

 

</form>

</

body>

</

html>


Page2.aspx.cs

protected

void Page_Load(object sender, EventArgs e)

{

string filename = Server.MapPath("myfile.xls");

HttpContext context = this.Context;

context.Response.Buffer =

true;

context.Response.Clear();

context.Response.ClearContent();

context.Response.ClearHeaders();

if (File.Exists(filename))

{

context.Response.ContentType =

"application/vnd.ms-excel";

context.Response.AddHeader(

"content-disposition", "attachment;filename=myfile.xls");

context.Response.TransmitFile(filename);

}

else

{

context.Response.Write(

"file not found");

}

context.Response.Flush();

context.Response.End();

}



1 Answer, 1 is accepted

Sort by
0
Kevin Babcock
Top achievements
Rank 1
answered on 31 Jul 2008, 08:59 PM
Hello Nirnay,

The reason for your problem is that when you click the button an asynchronous call is being made to the server. However, on the server you are redirecting to a new page. The originating call never returns to the client (instead, the client receives a response telling it to redirect to the new page) and thus the ResponseEnd event is never raised.

I hope this clears up your confusion. If you have further questions, please feel free to ask.

Regards,
Kevin Babcock
Tags
Ajax
Asked by
Nirnay Bansal
Top achievements
Rank 1
Answers by
Kevin Babcock
Top achievements
Rank 1
Share this question
or