PC Review


Reply
Thread Tools Rate Thread

Close window after file transmit (ASP)

 
 
=?Utf-8?B?QmlsbCBCZWxsaXZlYXU=?=
Guest
Posts: n/a
 
      2nd Aug 2004
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

 
Reply With Quote
 
 
 
 
=?Utf-8?B?QmlsbCBCZWxsaXZlYXU=?=
Guest
Posts: n/a
 
      6th Aug 2004
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');self.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
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to code a batch file to close window? Eric Windows XP General 9 21st Dec 2009 09:37 AM
Re: Batch file to close a window GTS Windows Vista File Management 0 30th May 2009 03:23 PM
transmit file to ftp server Mike W Microsoft VB .NET 2 30th Nov 2005 01:46 PM
Re: Force Batch file DOS Window to close LiquidJ Microsoft Windows 2000 Developer 0 28th Oct 2003 09:41 PM
Force close batch file DOS window Orlando Calderon Microsoft Windows 2000 CMD Promt 1 28th Oct 2003 06:11 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:36 PM.