How To Postback A Page After A File Download

Nov 18, 2010

The user click on a LinkButton, and the page does a PostBack. But I also need to prompt a file download to the user at the same time.

In order to do that, I did this on the LinkButton

lnkPrint.Attributes.Add("onclick", "window.open('Download.ashx?type=x')");

The Download.ashx Http Handler generates the file (Content-Type : application/pdf), and if I click on my LinkButton, it does PostBack and download the file after showing a popup... But I can't manage to close this popup automatically.

I tried some methods

settimeout('self.close()',1000) after the download Setting a RegisterStartupScript on the LinkButton.Command, to trigger the download after the postback, but IE6 prompts a warning that disturbs my users

So, none of these methods seems to work fine.

So, my question is : Is there a way to make the popup instantly disappear, or is there a means to make the page download the file AND postback at the same time ?

PS : I thought of the Your download will begin shortly method, but I'm afraid I'll have the same issues as before with the RegisterStartupScript...

View 2 Replies


Similar Messages:

HttpHandlers / Modules :: Redirect Shareware Download URL From A File To A Download Page?

Oct 13, 2010

I'm about to submit my pad file to multiple sharware sites but the pad file has to have a direct link to the download file and can't link to a download page which is what I would like to do, so I can track the traffic and get the downloader's email before allowing the download. I am running an ASP.NET site in VB. Is there a way to tell the web app to redirect to a specific aspx page when it receives a request for a specific file?

View 1 Replies

C# - Start A File Download After A Postback?

Feb 7, 2011

In my application I am building a zip file for the User to download for some exported database information. The zip file is created when the user clicks a "generate data" button and I log the request in the database.

On my page, I have a Gridview which shows the download history of the User and also offers them the ability to download the latest generated file for a set period of time.

The issue I'm having is when they click the button, I'd like the page to refresh (thus refreshing the gridview and showing their latest request) and then start the file download for them (IE, bring up the prompt and let them decide whether to open/save/cancel it).

I'm able to start the download on a post back, but my Gridview is not updating before it begins so it doesn't show the newest request in the list. How can I get the gridview to update BEFORE the download prompt starts?

I'm using the following to start the download:

public void BeginDownload()
{
FileDownload download = InventoryService.GetLastThreeFileDownloads(this.EmployeeId).First();
FileInfo fi = new FileInfo(Server.MapPath(SERVER_DOWNLOAD_PATH) + download.DownloadFileName);
Response.Clear();
Response.ContentType = "application/zip";
Response.AppendHeader("Content-Disposition", "attachment; filename=" + fi.Name);
Response.TransmitFile(fi.FullName);
Response.Flush();
}

The method is called in the Page_Load event as the last item, if a hidden field is set to true (which I set when they click the button to build the file).

I've also tried doing this through jQuery / AJAX calls to either refresh the page and start the download with little success. I have thought about opening a modal dialog and letting them click a link to start the download and then refresh the page when the modal closes, but that's a last resort if I can't find another solution.

View 3 Replies

Creating Mobile Website Page To Download Symbian .sis File To Mobile Unable To Download Properly

Dec 10, 2010

i m creating asp.net Mobile website page to download symbian .sis file to mobile ,but its not geting download properly.its working perfectly on desktop.

View 2 Replies

Download The Pdf File From Page?

Sep 14, 2010

how to download the .pdf file from the .aspx page

View 5 Replies

File Download Page

Dec 21, 2011

I am writing something that will use my database to generate/populate some Word/Excel Template Documents for Contracts. These will be written to a directory on my server that I want my user to be able to have access to to download these contracts from. I was thinking a GridView with a TemplateField with a Hyperlink in it for simplicity's sake.

View 3 Replies

C# - Update Page After File Download?

Oct 26, 2010

I put together a download script after some wonderful help from stack overflow the other day. However I've now found that after the file has been downloaded I need to reload the page to get rid of the progress template on the aspx page. The code to remove the template worked before I added in the download code.

Code to remove progress template: upFinanceMasterScreen.Update();
I've tried calling putting this before and after the redirect to the IHttpHandler
Response.Redirect("Download.ashx?ReportName=" + "RequestingTPNLeagueTable.pdf");

[code]...

View 1 Replies

Web Forms :: Display Page And Then Download File?

Oct 25, 2010

I am trying to accomplish something that websites like CNET do for downloading.

When a button on a page is clicked I want the user to be taken to a page..called download.aspx, the whole page is displayed with information

like "your download is starting..." and then the file is presented to be download.

What I did.

In my main page on the button click event...I do a Response.Redirect("download.aspx"); and in the download.aspx page

load event I present a Response.TransmitFile("myfile.exe");

This doesnt work because the download.aspx is NOT rendered untill the whole download is finished.

View 4 Replies

Web Forms :: Download A File Then Navigate To A Different Page?

Dec 20, 2010

how to download a file from a button_click event and when the file has finished downloading to transfer to another web page. vb.net

e.g

Dim
myFilepath As
String =
"c:ClientsCL592australiapos.com.auPublic_htmldownloadsSAMSAM.msi"

[Code]....

View 3 Replies

Page To Download A File Requires Processing In Webclient?

Jan 11, 2011

I'm trying to use a java servlet in a 3rd party tool's web interface (CA service desk) to invoke it's download file functionality using a webclient in vb.net. The trouble is the text stream from response is markup and not the acutual text file stream.

It's like the page is redirecting to another page which actually presents the file for downloading. I have no idea what the redirected page URL is.

Is there a way I can process this redirected page in order to get at the download using a system.net.webclient?

View 1 Replies

How To Launch The Download Of A File Without Leaving The Current Page

Mar 2, 2011

How can I force the download of a file on a ASP.NET page using datas from that page's ViewState?

Response.ClearContent();
Response.ContentType = "text/plain";
Response.AddHeader("Content-Disposition", "attachment; filename=" + "example.aaa");
Response.Write( this.ViewState["stuffs"] );
Response.End();

But if I do that the current page will be erased and return blank to the user.

Other examples says to create "download.aspx" and request it by javascript, but on a this new page I won't have access to the ViewState data of the first page.

The point is, how can I create a file, launch the download and don't lose the current page status?

View 2 Replies

Show Download Dialog Box In Case Of File Download - Located On Amazon Server

Jan 4, 2010

i am using amazon s3 service. now i want to show download dialog box in my asp.net application when user come on download page. i am using amazon sdk.

View 1 Replies

AJAX :: Download LinkButton In UpdatePanel Throwing Error While File Download?

Jun 10, 2013

I have added linkbutton inside gridview to download, below is my code..

protected void lnkDownload_Click(object sender, EventArgs e)
{
try
{

[Code].....

its giving me following error

"Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack"

View 1 Replies

Web Forms :: Download File Using New Window When Download Button Is Clicked

Sep 2, 2013

I need to download  a .mp3 file from a folder. during download a new blank page should open and after downloading it should close automatically.

View 1 Replies

Ajax - How To Return An Error From A File Download Action Without Leaving The Current Page

Jul 12, 2010

I am calling a file download action from javascript:

$elem.click(function() {
window.location.href = 'MyController/MyFileDownloadAction';
});

The controller returns a file:

[code]...

This action has a pretty high likelyhood of throwing an exception (or at least not being able to return the file).

Due to the nature of the application (which contains a lot of dynamic content), I can't really redirect to an error page in this situation. The current page needs to stay open somehow.

So I'm ideally looking for something like a javascript pop-up, but afaik this isn't going to be possible since I don't know any way to return a javacript instruction in a non-ajaxed controller call. If I display an error page I need to force it to open in a new window some how. Is there any possible solution to this problem?

View 1 Replies

Forms Data Controls :: How To Download A File Then Either Redirect Or Refresh The Page (after Response.end)

Oct 12, 2010

I am using some code similar to the code below to open a word document on my ASP.net app. Once the file has been downloaded and opened I then want to either redirect to another page or refresh the screen but nothing works after response.end and if i add it before response.end the browser never downloads the file?

[Code]....

[Code]....

View 6 Replies

Web Forms :: Download Binary File From Database Inside Page Load Event

Sep 20, 2015

I want to download a file from database using asp.net c# code in page load event.My table design as below

Table Name: tblFiledownload
Id - int
Data - varbinary(MAX)
FileName - varchar(50)
FileExtension - varchar(50)

View 1 Replies

Web Forms :: Controlling File Name Of The File Opened Directly From File Download Dialog?

Jul 26, 2010

I am downloading file from database using the following code. This code downloads an excel file from the database which has a macro attached to it when it is opened. This macro reads file name of the excel file and uses it for its computation. Everthing works file if user saves the file on his harddisk and then open if but if he directly opens the file from the dialog(by hitting 'Open' button) then file name of the opened excel file comes out be the name of the webform that has the above code and this leads to error in the macro. Is there any option through which i can control the name of the file if user directly opens the file from dialog or the option to disable or remove 'Open' button form the dialog?

[Code]....

View 2 Replies

AJAX :: Remain File Selection In Fileupload Control After Page PostBack?

Apr 27, 2016

i have searched on google and got an article [URL] keep selected file in fileupload control even after page postback. But it's not working at all. So is there any way through which we can keep selected files in fileupload even after page postback.?

View 1 Replies

Forms Data Controls ::Postback Of Page Using JavaScript Postback's Slow Down The Page?

Sep 22, 2010

I'm at my wits end on this one looked/Searched/Played/Experimented and I need your help if you can.This page is going to be primarily used on a mobile device using Win Mobile 5 Need to Accomplish:Prevent Postback(serverside) of Page using JavaScript (Postback's slow down the page on mobile device)

[code]...

View 1 Replies

AJAX :: AsyncFileUpload And GridView - Getting The Partial Page Postback To Fire After The File Upload Has Completed

May 28, 2010

I have two controls, each placed in their own <div> and <UpdatePanel> on my form. I am having trouble getting the partial page postback to fire after the file upload has completed. I have not used the __doPostBack approach before so I'm not sure if I am heading in the right direction.

View 6 Replies

Viewing File Using .net / To Copy/download File To Local User Machine And To Open

Nov 16, 2010

In our application, we allow user to upload documents which can be PDF, Doc, XLS, TXT. Uploaded documents will be saved on web server. We need to display link for each document user uploaded and when user click on that link, it should open relevant document. it is expected to have required software to open relevant documents.

To upload document, we use saveAs method of FileUpload control and it works absolutely fine.Now, how to view it?I believe, i need to copy/download file to local user machine and need to open it using Process.Start.For that i need to find user local temp directory. if i put path.GetTempPath(), it gives me web server directory and copy file there.

File.Copy(
sPath + dataReader["url"].ToString(),
Path.GetTempPath() + dataReader["url"].ToString(),
true);

View 4 Replies

Web Forms :: Can't Start File Download From Server Side Using .aspx File In IE7

Mar 26, 2011

This below code i have used in my aspx page for file download.

Response.AppendHeader("content-disposition", "attachment; filename="" + emailAttachment.FileName + "";");
Response.ContentType = "application/octet-stream";
Response.OutputStream.Write(emailAttachment.Data, 0, emailAttachment.Data.Length);
Response.End();

This block of code display Download file Dialog for Open or Save the attached file.It's working fine in Mozila Firefox and IE8 but doesn't display Download file Dialog box in IE 7

View 2 Replies

Web Forms :: Secure File Download / Hide File Path And Location While Downloading Files

Jan 14, 2013

I have made an application where I am displaying the .pdf , .doc , .docx  files. These files are uploading from an Admin Panel.When user place a mouse pointer on download icon provided in front of every file, it shows the complete path where it’s get saved.I want to avoid this path visibility even when user place mouse on download icon and even if it Inspect an element (as most modern browser will have this functionality).

View 1 Replies

IE Errors On File Download Through .ashx File With Caching Turned Off?

Feb 1, 2011

I have a simple 'file download' generic handler which sets the response contenttype and headers before sending the file through the same response.

I also have Response.Cache.SetCacheability(HttpCacheability.server) set in the global.asax.

As I have noticed from various sources, Internet Explorer doesn't like this no-cache setting and gives an error when trying to download the file (requested site unavailable or cannot be found).

I thought maybe I could override this setting in the .ashx page, so I alter the response's cacheability setting to public. This did not solve the issue. removing the line from global.asax does solve the problem but obviously affects the whole site.

Is there a way of setting the cachability just for my generic handler?

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved