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();
}