.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Pankaj Mishra
alex morco
Imran Ghani

Home >> Code Snippets >> ASP.NET Controls >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

How to open .doc,.pdf.ms-excel files in asp.net 2.0..

Posted By:susant       Posted Date: October 01, 2008    Points: 10    Category: ASP.NET Controls    URL: http://www.dotnetspark.com  

open .doc, .pdf, .ms-excel files in asp.net 2.0. in a web browser. its simple.below is the steps to open word file, PDF file or you can open MS Excel file.

1: Take Two forms (source.aspx, Read.aspx)

2: Create one new folder on your solution explorer name it as Course

3: Add one existing item as example I added one ImageExample.pdf file

4: Take one button on that source.aspx

5: button_click event on source.aspx form

string id = "ImageExample.pdf";

 Response.Redirect("source.aspx?id=" + id);

6: Add this code on the page_load event of Read.aspx form

string str = Request.QueryString["id"].ToString();

        string file_path = Server.MapPath("~/course/" + str);

        string path = file_path;





// if it is a pdf file then else see next page what content type u have 2add

        Response.ContentType = "application/PDF";






Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend