Opening a pdf with window.open

Joined
May 29, 2008
Messages
1
Reaction score
0
I have a list of files in a GridView and I made a LinkButton for each row that contains the full path to the file. They are all pdf files on a network drive. I want the user to be able to click the button and view the pdf in a new window. When I click the button I get a 404 not found error even though I have verified that it is definitely passing the name of a valid file. Here is my code. Am I doing something obviously wrong?

Code:
protected void gvwSearchResults_RowCommand(Object sender, GridViewCommandEventArgs e)
{
        if (e.CommandName == "Select")
        {
            // Convert the row index stored in the CommandArgument
            // property to an Integer.
            int index = Convert.ToInt32(e.CommandArgument);

            // Get the file path from the appropriate
            // cell in the GridView control.
            GridViewRow selectedRow = gvwSearchResults.Rows[index];

            LinkButton tempButton = (LinkButton)selectedRow.Cells[4].Controls[0];
            lblNoResults.Text = "test: " + tempButton.Text;

            string scriptString = "<script language='javascript'>window.open('" + tempButton.Text + "');</script>";
            ClientScript.RegisterClientScriptBlock(this.GetType(), "PopUpwindowOpen", scriptString);
        }
}

Thanks for any insight.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top