Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / May 2007

Tip: Looking for answers? Try searching our database.

ASP.NET 2.0 - How to refresh page after download

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jurjen de Groot - 28 May 2007 09:14 GMT
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 System.IO.FileInfo(FullFileName);
System.Web.HttpContext.Current.Response.Clear();
System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition",
"attachment; filename=" + DownloadFileName);
System.Web.HttpContext.Current.Response.AddHeader("Content-Length",
objFI.Length.ToString());
System.Web.HttpContext.Current.Response.ContentType =
"application/octet-stream";
System.Web.HttpContext.Current.Response.WriteFile(objFI.FullName);
System.Web.HttpContext.Current.Response.End();

This works perfectly but after downloading, the page on wich the
download/export was initiated doesn't update, the lblMessage isn't updated
as is a button wich should become visible after download. I'm not sure how
to accomplish this.

Could anyone point me in right direction.

TIA,
Jurjen.
Peter Bromberg [C# MVP] - 28 May 2007 12:37 GMT
When you replace the Response with a file download and call Response.End,
that's the end of the Response and you will get no more.

I'd try issuing the download from a popup window that uses a second page,
leaving your first page alone.
Peter
Site:  http://www.eggheadcafe.com
UnBlog:  http://petesbloggerama.blogspot.com
Short urls & more:    http://ittyurl.net

> I have an 'Export' button on my page, when clicking this button, a file is
> streamed to the client like this :
[quoted text clipped - 20 lines]
> TIA,
> Jurjen.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.