[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Opening Word in Browser

Posted on 2009-04-20
9
Medium Priority
?
1,078 Views
Last Modified: 2012-05-06
I have a link when clicked should open the word document in browser. here i am getting open and save option but my requirement is the file should be opened directly in the browser without asking user to save or open. please help
aspx page
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="test.aspx.cs" Inherits="TrainingCenter_test" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click">LinkButton</asp:LinkButton></div>
    </form>
</body>
</html>
 
 
code file 
using System.IO;
 
public partial class TrainingCenter_test : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
 
    }
    protected void LinkButton1_Click(object sender, EventArgs e)
    {
        string path = "123.doc";
        string fname = "123";
 
        string strPath = Server.MapPath("..\\Head_Office_Content" + "\\" + path);
 
        if (File.Exists(strPath))
        {
           Page.RegisterStartupScript("k", "<Script>window.open('" + "../Head_Office_Content/" + fname + ".doc" + "','" + fname + "','maximize=true,top=0,resizable=0,left=0,Width=1010px,Height=680px,status=0,toolbar=0,menubar=0,fullscreen=0, scrollbars=yes, location=0');</Script>");
        }
        else
        {
            Response.Write("File not found");
        }
    }
}

Open in new window

0
Comment
Question by:mannevenu
  • 4
  • 3
  • 2
9 Comments
 
LVL 28

Expert Comment

by:sybe
ID: 24183391
It is a client setting, something in the registry of the client. There is nothing you can do with your code on the server.
0
 

Author Comment

by:mannevenu
ID: 24183423
ooppss
but can I take the file contents and display in browser using Response.write();
0
 
LVL 28

Expert Comment

by:sybe
ID: 24183435
It isn't easy to take the file contents of a Word document, but in theory it is possible.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:mannevenu
ID: 24183452
hmmmm can u help me
in theory it is possible?i dint get u? how can i do that
0
 
LVL 14

Expert Comment

by:GiftsonDJohn
ID: 24183507
Hi,

It is a security settings from Internet Explorer by default it will prompt whether to open or save the file. This is to prevent from downloading any harmful attachments.

If you really want to prevent the dialog you can use the following link. This settings has to be done on every client's machine.

http://www.mydigitallife.info/2007/06/15/disable-automatic-opening-or-saving-of-downloads-re-enable-always-ask-before-check-box/
0
 
LVL 14

Expert Comment

by:GiftsonDJohn
ID: 24183513
If you want to read the contents from word and display in browser, you can use the following 3rd party component.

http://www.aspose.com/categories/file-format-components/aspose.words-for-.net-and-java/default.aspx
0
 

Author Comment

by:mannevenu
ID: 24183520
well this is not my requirement, well ok can i open atleast text file in browser using asp.net?
0
 
LVL 14

Accepted Solution

by:
GiftsonDJohn earned 2000 total points
ID: 24183547
0
 

Author Comment

by:mannevenu
ID: 24183569
ok i will check this
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question