Click here to Skip to main content
15,886,919 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello Team

How can we display any document right inside IE browser, without launching in any other Application separately?
Posted
Comments
R. Giskard Reventlov 27-Feb-12 13:20pm    
What have you already tried for yourself?
Roancho Khan 27-Feb-12 13:30pm    
Hello Mark,

Thank you for the Quick response

I have being trying this from last 15 day , Searched in google not got any think till now.

Below are the ways I tried for opening the Document in the browser.



1) Opening the doc in the Browser

2) Copy the content of the file and save it in the rich text control

3) Tried with different approach for the content code.

4) Tried with iframe control.

5) Tried with the HKEY_LOCAL_MACHINE code

6) Tried to change the file in the jpg format.

Thank you in advance





R. Giskard Reventlov 27-Feb-12 14:08pm    
Read Mark's response below: he is perfectly correct and you should take the time to research and learn how to do things for yourself rather than expect an answer be spoon-fed: you'll learn nothing that way.

1 solution

You can't control every type of document. For instance, if the user has MS Word on their machine and they click a link to a Word document it will open in the client application. The same for other types of applications. The browser will first search for available plugins or handlers. If you want to guarantee opening in the browser then you would need to read the file and use Response.Write or Response.WriteBinary.
 
Share this answer
 
Comments
Roancho Khan 27-Feb-12 13:37pm    
Hello Mark,

Thank you for the response.

Can you please tell us how we can read any document and use the Response.Write or Response.WriteBinary ??

Thank you
[no name] 27-Feb-12 14:01pm    
Is Google broken?
Roancho Khan 27-Feb-12 16:25pm    
sorry mark, I got the code to read the data from the document but it is not displaying the data properly it is displayin some junk data or encrypted data

Below is the code

string[] lines = System.IO.File.ReadAllLines(@"C:\Inetpub\wwwroot\please wait\Attachments\test.doc");

// Display the file contents by using a foreach loop.
System.Console.WriteLine("Contents of WriteLines2.txt = ");
foreach (string line in lines)
{
// Use a tab to indent each line of the file.
Response.Write("\t" + line);
}


Thank you

Sergey Alexandrovich Kryukov 27-Feb-12 17:24pm    
Agree, a 5.
--SA
Roancho Khan 28-Feb-12 9:49am    
Hello SAKryukov,

Is there any other option so that i can implement this logic.-Thank You

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