0

I have retrieved the pdf file from Database and linked it to a "a href" tag to open pdf file using link. Now I want to give the open/save dialog box before a pdf file opened . - in javascript(by using onclick event in "a" tag to call the javascript)

1 Answer 1

2

You have to set the content-disposition header using C# to get this behavior in a browser.

Read this for more info

How do I prompt a "Save As" dialog for an accepted mime type?

Downloading a File with a Save As Dialog in ASP.NET

Example

Response.Clear();
Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName);
Response.AddHeader("Content-Length", targetFile.Length.ToString);
Response.ContentType = "application/pdf";
Response.WriteFile(targetFile.FullName); 
Sign up to request clarification or add additional context in comments.

1 Comment

+1, here's another related SO post: stackoverflow.com/questions/1024910/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.