473,382 Members | 1,375 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

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

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

Feb 9 '06 #1
2 4373
VK
Message-ID: <XF********************@news20.bellglobal.com>

<http://www.peterprovost.org/archive/2003/05/20/483.aspx>

Feb 9 '06 #2

"VK" <sc**********@yahoo.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
Message-ID: <XF********************@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>
</p>
<p>
<button onclick="window.close();">Close</button>
</p>
</body>
</html>
------------------------------------------------
Feb 10 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Steve Mauldin | last post by:
This is a standard ASP application that has several pages at the root withthe global.asa. I set a session variable session("accountid") = "123456" within an asp page and then response.redirect to...
0
by: djus | last post by:
Hello At the begining I'm sorry for my English :( I want my aspx page TestPage.aspx to inherit from MyClass2. MyClass2 inherits from MyMainClass which is subtype of Page: public class...
0
by: Wictor Wilén | last post by:
Heya, I need help creating a download page that should be used to download files from a server, and the files on the server contains filenames that contains non-us characters such as the swedish...
5
by: tshad | last post by:
Is there a way to carry data that I have already read from the datagrid from page to page? I am looking at my Datagrid that I page through and when the user says get the next page, I have to go...
3
by: Jeff Jarrell | last post by:
I want to setup a downloads page on my site. Most of the time they are zip files but they are also MSI files. Things work ok if I simply put an <a> element referencing the file to download but...
1
by: Brett Kelly | last post by:
Ok, I know this sounds odd. Let me explain further. I have an ASP.net page (w/ C# code behind) that, when given a session variable containing the path to a local file, will attempt to start the...
3
by: kosmodisk | last post by:
Hi, I'm having problem accessing javascript-created elements from opened window. This occurs only when I'm including another files in opened window, javascript or css. When I comment out...
4
by: igotyourdotnet | last post by:
Is there a way to pass data from page to page without the use of a Session Variable or queryString? I need to pass drop down box selections from page to page and have the drop downs on the page be...
1
by: Zuhaib Hyder | last post by:
how to logout from frame window/page to normal window/page (no frame)? and how to open new normal page(no frame) from frame page?
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.