473,326 Members | 2,061 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,326 software developers and data experts.

Close window after file transmit (ASP)

Hi all,

This is partially a .NET question and partially scripting (whichever works :)

I recently wrote a vCard parser that sends vCards directly to the brower as a stream. After the file is transmitted I need to close the window, but I can't get anything to works because I’m ‘hijacking’ the Response.Write method.

Here is a small snippet of the code:

string strDN = "CN=Brigit Runge,OU=TestUsers,DC=engineering,DC=somewhere,DC= com";
DirectoryEntry deUser = new DirectoryEntry("LDAP://server/" + strDN);

string strCN = deUser.Properties["cn"].Value.ToString();
string strvCard = BuildvCard(deUser);

Response.AddHeader("content-disposition", string.Format("attachement; filename={0}.vcf", strCN));

Response.ContentType = "text/x-vcard";

Response.Write(strvCard);

Response.Write("<script>self.close();</script>");

//Response.End();

I've tried a number of script attempts, from onClick to onBlur. Any successful window closing prohibits the actual file transfer. I could use a timer, but I want to make sure the file actually gets sent.

Any ideas?

Thanks,
Bill

Jul 21 '05 #1
1 2412
I decided the better way was to separate the functionality and make a second
page. I was using two pages anyway, a window with an iframe pointing to the
real window. It is possible to post back to a modal dialogue, but posting
back a file wasn't working. Instead of opening the save/open window, the
modal was going blank -- consequently I resorted to the iframe/modal hack.

The solution:
Open a second window that simply renders the vCard and then have the modal
close itself.

Remember that to get a modal to postback and close itself you must:

Set HTML/JScript:
<base target="_self">
window.opener = this.self;

C#:
Response.Write(string.Format("<script>window.open( 'vCardBuilder.aspx?adObject={0}&action=browser');s elf.close();</script>", strPath));

Now I need to figure out how to parse a photo into a vCard, it sounds easy
but I keep crashing Outlook *evil grin*

Bill
Jul 21 '05 #2

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

Similar topics

1
by: Navin | last post by:
i open the file download.asp from another main.asp page using window.open what the problem is when i clikc on the hyperlink it prompts me the ie save dialog box taht fine. but when the script...
1
by: Joe D | last post by:
I think this is a simple question. But I am new to JS. Here is what I want to do: From a parent window, open a popup window (child) to get data from user, then user submit the request, close the...
6
by: chon | last post by:
I have an ASP page that is sent a file location as a parameter. It opens this file, loads the ADODB.Stream object and does a binary write to the page forcing the download dialog to appear. This...
1
by: Bill Belliveau | last post by:
Hi all, This is partially a .NET question and partially scripting (whichever works :) I recently wrote a vCard parser that sends vCards directly to the brower as a stream. After the file is...
5
by: lindanr | last post by:
In ASP.NET 2005 I have an onblur="window.close()" javascript event in the <body> tag. When I click on the window's scrollbar, the window closes. The same code works fine in ASP.NET 2003. Any...
9
by: Stan B | last post by:
I create a popup window by calling window.showModalDialog Popup window has Ok button with this code attached: === string Script = "<script language=JavaScript>" + "{" + "window.close();" +...
37
by: Jan Tovgaard | last post by:
Hey everyone:) We have a critical problem, which I can see that other people also has ran into. In Internet Explorer 7 it is no longer possible to do a window.close after opening a window,...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.