473,466 Members | 1,465 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

closing web page that initiated a download?

Two questions:
1. I have several asp.net pages that initiate a file download, via
Response.WriteFile(). This works fine, except that it leaves the original
page up. These pages are generally launched in new windows, so I'd prefer
that they go away by themselves.
Can anyone suggest a way to have the page close by itself?

2. I have tried to disable the remaining page so that the user can't
re-submit. While it's easy enough to toggle off the buttons, an Enter key
causes a Submit, which ASP.Net (1.1) interprets as the first button (in this
case the one I'm trying to disable.
What's the cleanest way to prevent a page from being able to Post back?

Thanks.
Jul 27 '07 #1
1 1619
It can be hard to have a window close itself without a client-side event
firing, so it sounds to me like the best thing to do would be to use the
onblur javascript eventhandler to call the window.close() method. If
pressing the enter key causes a resubmit, I would take a look at your
existing code and possibly add or modify something to detect that (I can't
help you do that right now, because I can't see your current code). If you
want to make sure the download finishes before closing the window, a
technique that I once used on an ASP.NET page of mine was to have ASP.NET do
a Response.Redirect to a page with nothing on it except the following:

<html><body onload="window.close();"></body></html>

Using this technique allows ASP.NET cause you to leave the page that
initiated the download by using the Response.Redirect, and then have a
client event get called to allow you to close the new window, leaving you
with a net result of both windows being closed. It may involve creating an
extra page, but the user will probably not even notice the extra page, and
it is a very small page that doesn't even have to be an aspx page. Good
Luck!
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"ChrisA" <Ch****@discussions.microsoft.comwrote in message
news:1B**********************************@microsof t.com...
Two questions:
1. I have several asp.net pages that initiate a file download, via
Response.WriteFile(). This works fine, except that it leaves the original
page up. These pages are generally launched in new windows, so I'd prefer
that they go away by themselves.
Can anyone suggest a way to have the page close by itself?

2. I have tried to disable the remaining page so that the user can't
re-submit. While it's easy enough to toggle off the buttons, an Enter key
causes a Submit, which ASP.Net (1.1) interprets as the first button (in
this
case the one I'm trying to disable.
What's the cleanest way to prevent a page from being able to Post back?

Thanks.

Jul 28 '07 #2

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

Similar topics

22
by: Theo | last post by:
Question for the group The authentication system for the site Im working on seems to function properly and all is good. A session keeps track of everything and a cookie is used to accept or deny...
4
by: Roy | last post by:
Maybe I am in the wrong place and doing this the wrong way... please tell me if you think there is a better way. I need to transfer some files from a server to the client workstation. The...
2
by: Colin Basterfield | last post by:
Hi, Hmmm, a strange one for me, but hopefully not for others... I have a base page which has virtual protected void PageLoadEvent(object sender, System.EventArgs e){} In the Page_Load...
1
by: Pavils Jurjans | last post by:
Hello, I need some advice, how to set up the following: I have a web application, written in ASP.NET. User can ask this application to prepare some report, that takes much processing time,...
9
by: PK9 | last post by:
I'm having an issue with the "Refresh" of an asp.net page. The refresh is actually calling my last onClick event. I thought that asp.net was supposed to be stateless in that it shouldn't...
5
by: Russell | last post by:
Hi all, I have a web page(a) that has a link to another web page(b). Now, on the page load event of web page(b), I am doing the following: Response.redirect("./test.pdf") This pdf, if the...
7
by: Rich | last post by:
I have the following script on all pop up windows, would like to have this work on all newer browsers if possible. Right now it only works on MSIE & Opera. Not sure why. Any suggestions are...
1
by: Jurjen de Groot | last post by:
I have an 'Export' button on my page, when clicking this button, a file is streamed to the client like this : lblMessage.Text = "Thank you for downloading..."; System.IO.FileInfo objFI = new...
41
by: Twayne | last post by:
Hi, How would I go about "forcing" a user from one page to another? I have a very simple random question/answer entrance requirement for an e-mail form. After 3 page views most people are...
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:
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.