Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET C#4.0 C#3.5 , +
I need to display uploaded files in new window or same window of browser on Linkbutton's click event.
 
I'm able to get path of file.
 
Whether file exists or not is already checked, but I'm not able to OPEN file.
 
Files are uploaded at Inetpub\wwwroot\
(i.e. C:\Inetpub\wwwroot\ApplicationFiles\Template\1.pdf)
File path is saved in database.
 
Thanks in Advance!
Posted 9-Apr-11 2:55am
Edited 9-Apr-11 3:10am
v2
Comments
Dalek Dave at 9-Apr-11 9:11am
   
Edited for Grammar and Readability.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

This could be a difficult question to answer, depending on the approaches you have attempted.
 
Please provide the code so that it can be studied.
(Not a complete codedump!, Just the relevent area Smile | :) )
 
There should be no readily apparent reason why a PDF is not opening, (Unless perhaps there is no PDF reader loaded? I presume this is not the case)
 
Another approach is to not load a PDF at all, and let the user choose to save once he has loaded it to his browser (This is an approach I favour with my company's website).
 
Either way, code would allow us to provide a better, more suitable answer for you.
 
Cheers.
 

 

 
Mark up if helpful!
  Permalink  
Comments
Dave Parth at 11-Apr-11 0:22am
   
Can you please provide me code for the scenario you use. (let the user choose to save once he has loaded it to his browser)
 
I am doing this thing first time. So i don't have much idea of this. I know we can easily do this thing using anchor tag. But we want to use anchor.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Hi,
 
try this code to open pdf files in browser after uploading
 
        Response.Clear();
        Response.AddHeader("content-type", "application/pdf");
        Response.WriteFile(Server.MapPath("~/testingimages/sample2.pdf"));
        Response.End();
 
Here you've to mention the content type .
 
now all browsers supports pdf files to display directly
 

All the Best
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 371
1 Sergey Alexandrovich Kryukov 286
2 RyanDev 75
3 PhilLenoir 70
4 Pheonyx 50
0 Sergey Alexandrovich Kryukov 6,676
1 OriginalGriff 6,056
2 CPallini 2,473
3 Richard MacCutchan 1,697
4 Abhinav S 1,560


Advertise | Privacy | Mobile
Web03 | 2.8.140821.2 | Last Updated 28 Sep 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100