We help IT Professionals succeed at work.
Get Started

Force open / save pdf file in C# asp.net

ravi24june asked
Last Modified: 2012-05-06
HI friends,

 I m new in C#. I am facing a problem.
I m using a Grid view to display record from database. In one fileld the pdf file name is coming from database. On clicking of file name the pdf file is opening from the server.
 The problem is , pdf fileis directly open in browser or popup block the pdf file.

 I want to open a dialog box which asks for open save cancel for pdf file.

protected void DetailView_SelectedIndexChanged(object sender, EventArgs e)
        string filename=DetailView.SelectedRow.Cells[6].Text.ToString();
        if (filename == "")
            LblMsg.Text = "File is not Available";
           filename = Request.Url.AbsoluteUri.Substring(0, Request.Url.AbsoluteUri.LastIndexOf("/") + 1) + @"Published/" + filename;
           string popupScript = "<script language='javascript'>" +
                                  " window.open('" + filename + " ','_blank')" +
           Page.RegisterStartupScript("PopupScript", popupScript);

Open in new window

Watch Question
This problem has been solved!
Unlock 1 Answer and 7 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE