title: How to open image or pdf file in a new window?
body: <p>i have a gridview it contains file names and path of files (image and pdf format files) in that i used template field under that i put 1 image buttoon. on clicking of that image button i.e view button i want to open selected file in a new window. </p>
  
  <p>here is my code :</p>
  
  <pre><code>protected void GVViewFile_SelectedIndexChanged(object sender, EventArgs e)
  {
      int id = GVViewFile.SelectedIndex;
      string path = GVViewFile.Rows[id].Cells[2].Text.ToString();
  
      Response.Redirect("D:\UploadedAttachment\AT\MRD\AT0520130008_15-05-13-03-57-12.pdf");
  
      Response.Write("&lt;script&gt;");
     Response.Write("window.open('" + path + "','_blank', ' fullscreen=yes')");
     //Response.Write("window.open(" + path + ",'_blank')");
     Response.Write("&lt;/script&gt;");
  
  }
  </code></pre>
  
  <p>but i could not open in new window. my path returns same value as inside response.write(). whe i use just <code>response.write("images/UserDetails.pdf");</code> as example it will show pdf page..but full path is not taking. also it shows <code>'\'</code> is wrong in <code>response.write();</code> so how to use actual full path to display image or pdf in new window..please help me.even that window.open is giving error.i cannot write full path in window.open since i am getting selected path from gridview.help please....</p>
  
  <p>my gridview code :</p>
  
  <pre><code> &lt;asp:GridView ID="GVViewFile" runat="server" AutoGenerateColumns="False" 
          DataSourceID="DSforgridview" onselectedindexchanged="GVViewFile_SelectedIndexChanged"
          HeaderStyle-BackColor="#CC6600" HeaderStyle-ForeColor="White" 
      PagerStyle-BackColor="#CC6600" PagerStyle-ForeColor="White" CellPadding="3" 
      CellSpacing="3" PagerStyle-Width="4" PagerStyle-Height="4" 
      BorderColor="#FF6600" BorderStyle="Solid"&gt;
          &lt;Columns&gt;
              &lt;asp:TemplateField ShowHeader="false"&gt;
          &lt;ItemTemplate&gt;
              &lt;asp:ImageButton ID="btnView" runat="server" 
                  CausesValidation="False" CommandName="Select"
                  ImageUrl="~/Images/view.gif" ToolTip="View File" /&gt;
          &lt;/ItemTemplate&gt;
        &lt;/asp:TemplateField&gt;
  
              &lt;asp:BoundField DataField="FileType" HeaderText="FileType" 
                  SortExpression="FileType" /&gt;
              &lt;asp:BoundField DataField="FileLocationPath" HeaderText="FileLocationPath" 
                  SortExpression="FileLocationPath" /&gt;
          &lt;/Columns&gt;
      &lt;HeaderStyle BackColor="#CC6600" ForeColor="White"&gt;&lt;/HeaderStyle&gt;
      &lt;EmptyDataTemplate&gt;No Records Found.&lt;/EmptyDataTemplate&gt;
      &lt;/asp:GridView&gt;
  </code></pre>