Monday, March 26, 2012

Opening Word from .net

I can't seem to open a word document from any of my browsers except the one
on my web server.

Here is the .aspx file:

************************************************** ***************
<%@dotnet.itags.org. Import Namespace="System.Data.SqlClient" %>
<%@dotnet.itags.org. import Namespace="System.IO" %
<Script Runat="Server"
Sub Page_Load
Dim conPubs As SqlConnection
Dim cmdSelect As SqlCommand
Dim dtrAuthors As SqlDataReader

' Retrieve records from database
conPubs = New SqlConnection(
System.Configuration.ConfigurationSettings.AppSett ings("MM_CONNECTION_STRING
_Contour_Server"))
cmdSelect = New SqlCommand( "Select title,fullFileName From
openworx..QADocs order by title", conPubs )
conPubs.Open()
dtrAuthors = cmdSelect.ExecuteReader()

' Bind to Repeater
rptAuthors.DataSource = dtrAuthors
rptAuthors.DataBind()

dtrAuthors.Close()
conPubs.Close()
End Sub

</Script
<html>
<head><title>Repeater.aspx</title></head>
<body>
<form Runat="Server"
<asp:Repeater
ID="rptAuthors"
Runat="Server"
<ItemTemplate>
<a href="http://links.10026.com/?link=<%# Container.DataItem("fullFileName") %>" ><%#
Container.DataItem("title") %></a><br>
</ItemTemplate
<separatortemplate>
<hr></separatortemplate
</asp:Repeater
</form>
</body>
</html>
************************************************** **************************
*******

This gives me a list of files from my QADocs table that generates a page
like so:

************************************************** **************************
*****
<html>
<head><title>Repeater.aspx</title></head>
<body>
<form name="_ctl0" method="post" action="TMPbxwz1g6rr.aspx" id="_ctl0">
<input type="hidden" name="__VIEWSTATE" value="dDwtMjA0Nr9vNNYoX" /
<a href="http://links.10026.com/?link=c:\QA Docs\QSF 6.1.4 - Acknowledgmnt of Designated Reading.doc"
>Acknowledgement of Designated Reading</a><br
<hr
</form>
</body>
</html>
************************************************** **************************
**************

The link looks like this:

file:///c:/QA%20Docs/QSF%206.1.4%20-%20Acknowledgmnt%20of%20Designated%20Rea
ding.doc

As I said when I click on the link, a page opens up as a word document on
the web server, but not on any other workstation. It just sits there. How
do I get it to open the file?

Also, is there a way to tell the link to open up the file in a separate
window as well as to be read only?

Thanks,

Tom.Hi Tom:

To open a link in a new window, add target="_blank" as an attribute to
the href.

When you use an href like a href="http://links.10026.com/?link=c:\QA Docs\mydoc.doc", you are
telling the browser to open a docunment on the local drive C. Since
only the web server has the document on the C drive, it only works
from a browser on the server. When a remote client clicks the link the
browser tries to find the document on the remote machine's C drive.

You could keep the .doc files inside a virtual directory on your
weberver and provide a link with an HTTP URL.

HTH,

--
Scott
http://www.OdeToCode.com

On Mon, 26 Jul 2004 01:26:22 -0700, "Thomas Scheiderich"
<tfs@.deltanet.com> wrote:

>I can't seem to open a word document from any of my browsers except the one
>on my web server.
>Here is the .aspx file:
>************************************************** ***************
><%@. Import Namespace="System.Data.SqlClient" %>
><%@. import Namespace="System.IO" %>
><Script Runat="Server">
>Sub Page_Load
> Dim conPubs As SqlConnection
> Dim cmdSelect As SqlCommand
> Dim dtrAuthors As SqlDataReader
> ' Retrieve records from database
> conPubs = New SqlConnection(
>System.Configuration.ConfigurationSettings.AppSett ings("MM_CONNECTION_STRING
>_Contour_Server"))
> cmdSelect = New SqlCommand( "Select title,fullFileName From
>openworx..QADocs order by title", conPubs )
> conPubs.Open()
> dtrAuthors = cmdSelect.ExecuteReader()
> ' Bind to Repeater
> rptAuthors.DataSource = dtrAuthors
> rptAuthors.DataBind()
> dtrAuthors.Close()
> conPubs.Close()
>End Sub
></Script>
><html>
><head><title>Repeater.aspx</title></head>
><body>
><form Runat="Server">
><asp:Repeater
> ID="rptAuthors"
> Runat="Server">
> <ItemTemplate>
> <a href="http://links.10026.com/?link=<%# Container.DataItem("fullFileName") %>" ><%#
>Container.DataItem("title") %></a><br>
> </ItemTemplate>
><separatortemplate>
><hr></separatortemplate>
></asp:Repeater>
></form>
></body>
></html>
>************************************************** **************************
>*******
>This gives me a list of files from my QADocs table that generates a page
>like so:
>************************************************** **************************
>*****
><html>
><head><title>Repeater.aspx</title></head>
><body>
><form name="_ctl0" method="post" action="TMPbxwz1g6rr.aspx" id="_ctl0">
><input type="hidden" name="__VIEWSTATE" value="dDwtMjA0Nr9vNNYoX" />
> <a href="http://links.10026.com/?link=c:\QA Docs\QSF 6.1.4 - Acknowledgmnt of Designated Reading.doc"
>>Acknowledgement of Designated Reading</a><br>
><hr>
></form>
></body>
></html>
>************************************************** **************************
>**************
>The link looks like this:
>file:///c:/QA%20Docs/QSF%206.1.4%20-%20Acknowledgmnt%20of%20Designated%20Rea
>ding.doc
>As I said when I click on the link, a page opens up as a word document on
>the web server, but not on any other workstation. It just sits there. How
>do I get it to open the file?
>Also, is there a way to tell the link to open up the file in a separate
>window as well as to be read only?
>Thanks,
>Tom.
"Scott Allen" <bitmask@.[nospam].fred.net> wrote in message
news:f80ag01nk3grmjn6d3me562oinoeb3rekl@.4ax.com...
> Hi Tom:
> To open a link in a new window, add target="_blank" as an attribute to
> the href.

That was what I was looking for.

> When you use an href like a href="http://links.10026.com/?link=c:\QA Docs\mydoc.doc", you are
> telling the browser to open a docunment on the local drive C. Since
> only the web server has the document on the C drive, it only works
> from a browser on the server. When a remote client clicks the link the
> browser tries to find the document on the remote machine's C drive.
> You could keep the .doc files inside a virtual directory on your
> weberver and provide a link with an HTTP URL.

I was told it was dangerous to put Documents in a vitual directory as that
would leave them vulnerable. This was why I did it this way.

However, by doing this - it now works - as long as the person has Word on
his machine.

Is there a way to have the browser send the file already word formatted? If
there is no word on the machine, it displayes it as a text file which will
have all non text displayed as ascii and boxes (for non printable
characters).

Thanks,

Tom.
> HTH,
> --
> Scott
> http://www.OdeToCode.com
> On Mon, 26 Jul 2004 01:26:22 -0700, "Thomas Scheiderich"
> <tfs@.deltanet.com> wrote:
> >I can't seem to open a word document from any of my browsers except the
one
> >on my web server.
> >Here is the .aspx file:
> >************************************************** ***************
> ><%@. Import Namespace="System.Data.SqlClient" %>
> ><%@. import Namespace="System.IO" %>
> ><Script Runat="Server">
> >Sub Page_Load
> > Dim conPubs As SqlConnection
> > Dim cmdSelect As SqlCommand
> > Dim dtrAuthors As SqlDataReader
> > ' Retrieve records from database
> > conPubs = New SqlConnection(
>System.Configuration.ConfigurationSettings.AppSett ings("MM_CONNECTION_STRIN
G
> >_Contour_Server"))
> > cmdSelect = New SqlCommand( "Select title,fullFileName From
> >openworx..QADocs order by title", conPubs )
> > conPubs.Open()
> > dtrAuthors = cmdSelect.ExecuteReader()
> > ' Bind to Repeater
> > rptAuthors.DataSource = dtrAuthors
> > rptAuthors.DataBind()
> > dtrAuthors.Close()
> > conPubs.Close()
> >End Sub
> ></Script>
> ><html>
> ><head><title>Repeater.aspx</title></head>
> ><body>
> ><form Runat="Server">
> ><asp:Repeater
> > ID="rptAuthors"
> > Runat="Server">
> > <ItemTemplate>
> > <a href="http://links.10026.com/?link=<%# Container.DataItem("fullFileName") %>" ><%#
> >Container.DataItem("title") %></a><br>
> > </ItemTemplate>
> ><separatortemplate>
> ><hr></separatortemplate>
> ></asp:Repeater>
> ></form>
> ></body>
> ></html>
>************************************************** *************************
*
> >*******
> >This gives me a list of files from my QADocs table that generates a page
> >like so:
>************************************************** *************************
*
> >*****
> ><html>
> ><head><title>Repeater.aspx</title></head>
> ><body>
> ><form name="_ctl0" method="post" action="TMPbxwz1g6rr.aspx" id="_ctl0">
> ><input type="hidden" name="__VIEWSTATE" value="dDwtMjA0Nr9vNNYoX" />
> > <a href="http://links.10026.com/?link=c:\QA Docs\QSF 6.1.4 - Acknowledgmnt of Designated
Reading.doc"
> >>Acknowledgement of Designated Reading</a><br>
> ><hr>
> ></form>
> ></body>
> ></html>
>************************************************** *************************
*
> >**************
> >The link looks like this:
>file:///c:/QA%20Docs/QSF%206.1.4%20-%20Acknowledgmnt%20of%20Designated%20Re
a
> >ding.doc
> >As I said when I click on the link, a page opens up as a word document on
> >the web server, but not on any other workstation. It just sits there.
How
> >do I get it to open the file?
> >Also, is there a way to tell the link to open up the file in a separate
> >window as well as to be read only?
> >Thanks,
> >Tom.
Hi Tom:

I think if I had to display Word as text, I would have a batch process
on the server converting Word .doc files to text files. I know there
are some third party components to do this, perhaps there are even
some free ones.

Another option you might consider is linking to the free Word document
viewer:
http://www.microsoft.com/downloads/...&displaylang=EN

--s

On Mon, 26 Jul 2004 09:46:16 -0700, "Thomas Scheiderich"
<tfs@.deltanet.com> wrote:

<snip>
>Is there a way to have the browser send the file already word formatted? If
>there is no word on the machine, it displayes it as a text file which will
>have all non text displayed as ascii and boxes (for non printable
>characters).
>Thanks,
>Tom.

--
Scott
http://www.OdeToCode.com
"Scott Allen" <bitmask@.[nospam].fred.net> wrote in message
news:63eag0hbtqcks4nrnt81cnic2bh6hisul9@.4ax.com...
> Hi Tom:
> I think if I had to display Word as text, I would have a batch process
> on the server converting Word .doc files to text files. I know there
> are some third party components to do this, perhaps there are even
> some free ones.

I actually didn't want to convert them to text files, just wanted to send
them already formatted to the users machine, which may not be possible (or
plauseable) - especially with the tables and images and special formatting
and spacing.
> Another option you might consider is linking to the free Word document
> viewer:
http://www.microsoft.com/downloads/...9E60-E4F3-436D-
A5A7-DA0E5431E5C1&displaylang=EN
This looks interesting. I do remember somewhere that there was a way to put
a word document in an IFrame (which put all the normal window controls
around the Iframe. Not sure where I saw that, however.

Still can't figure out how to open the file as readonly. I suppose the only
way to do this is to actually set the file to readonly in Windows Explorer.

Thanks,

Tom.
> --s
>
> On Mon, 26 Jul 2004 09:46:16 -0700, "Thomas Scheiderich"
> <tfs@.deltanet.com> wrote:
> <snip>
> >Is there a way to have the browser send the file already word formatted?
If
> >there is no word on the machine, it displayes it as a text file which
will
> >have all non text displayed as ascii and boxes (for non printable
> >characters).
> >Thanks,
> >Tom.
> --
> Scott
> http://www.OdeToCode.com

0 comments:

Post a Comment