Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

CSV download problem from window.showModalDialog( ) opened page.

300 views
Skip to first unread message

John

unread,
Feb 9, 2006, 4:41:11 PM2/9/06
to
Hi,

I posted this earlier in microsoft.public.dotnet.framework.aspnet, but
didn't get a response, so I thought I'd try here.

Basically, I'm having a problem opening / downloading csv files when
generated from within a page opened with window.showModalDialog( ) ( IE6 ).

To isolate this problem, I've written 3 files (see below).
1. main.htm allows the user to open the page containing the link in a
regular window or one opened via window.showModalDialog( )
2. modal.htm provides a link to the aspx which generates the csv
3. csv.aspx generates a csv file

When I open modal.htm with window.showModalDialog( ), clicking the link does
nothing.
When opened in a normal window, clicking the link opens / downloads the
generated csv.

Does anybody know how I can get the generated file to download while keeping
the modal window?

Thanks in advance,
John

------------------------------------------------------------
-- main.htm
------------------------------------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<script language="javascript">
function openModalDlg()
{
window.showModalDialog( "modal.htm", "",
"dialogHeight:200px;dialogWidth:400px;");
}
</script>
</head>
<body>
<p>
Click <a href="#" onclick="openModalDlg();">here</a> to open modal dialog
</p>
<p>
Click <a href="modal.htm" target="_blank">here</a> to open in regular
window
</p>
</body>
</html>

------------------------------------------------------------
-- modal.htm
------------------------------------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<base target="_self">
</head>
<body>
<p>
Click <a href="csv.aspx">here</a> to generate csv file from this page.
</p>
<p>
<button onclick="window.close();">Close</button>
</p>
</body>
</html>

------------------------------------------------------------
-- csv.aspx
------------------------------------------------------------
<%
// set export header
Response.ContentType = "Application/x-msexcel";
Response.AddHeader("content-disposition",
"attachment;filename=test.csv");

Response.Write( "\"Col A\",\"Col B\",\"Col C\"");
Response.Write( Environment.NewLine);
Response.Write( "1,2,3");
Response.Write( Environment.NewLine);
Response.Write( "4,5,6");
Response.Write( Environment.NewLine);
Response.Write( "7,8,9");
Response.Write( Environment.NewLine);
Response.End();
%>

VK

unread,
Feb 9, 2006, 6:26:49 PM2/9/06
to

John

unread,
Feb 10, 2006, 9:31:43 AM2/10/06
to

"VK" <school...@yahoo.com> wrote in message
news:1139527609.4...@g47g2000cwa.googlegroups.com...
> Message-ID: <XFOGf.38057$1e5.6...@news20.bellglobal.com>
>
> <http://www.peterprovost.org/archive/2003/05/20/483.aspx>
>

Thanks VK,

That worked great.

For the record; here is my new modal.htm file


-----------------------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<base target="_self">
</head>
<body>
<p>

Click <a href="csv.aspx" target="ifrTarget">here</a> to generate csv file
from this page.
<iframe name="ifrTarget" id="ifrTarget" width="0" height="0"></iframe>

0 new messages