473,385 Members | 1,772 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,385 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 2413
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.