Click here to Skip to main content
15,892,737 members
Please Sign up or sign in to vote.
4.50/5 (2 votes)
See more: , +
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
Updated 9-Apr-11 3:10am
v2
Comments
Dalek Dave 9-Apr-11 9:11am    
Edited for Grammar and Readability.

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 :) )

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!
 
Share this answer
 
Comments
Dave Paras 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.
Hi,

try this code to open pdf files in browser after uploading

C#
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
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900