By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,053 Members | 1,615 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,053 IT Pros & Developers. It's quick & easy.

open text file in browser window using hyperlink

P: n/a
hi

I have hyperlink column in a datagrid. The column contains the name of
a text file.
I am able to appendthe full path of the file. The file is on D drive on
the server. But on clicking on that hyperlink does not open the file.
When I right click the link, I am able to save the file. I want the
file to be opne in browser in a new window.

I started a new webform and used a link
<a href='file:///D:/Test.txt' id ='hpl' runat='server'>test</a>
Even here it is not opening the text file. Is there any way to
hyperlink a text file in local disk on server and open it in a new
browser window

Can anybody help me out in this?

Thanks
Sohan

Mar 2 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hi Sohan,

Use Server.MapPath("Test.txt") to get the correct url. For this to
function the file has to be under the root of your asp.net application.

--
Ward Bekker
"Asp.Net Discussions for the Professional Developer"
http://www.dotnettaxi.com

"Free .Net 2.0 C# to/from VB.Net Code Converter"
http://www.dotnettaxi.com/Tools/Converter.aspx
Mar 2 '06 #2

P: n/a
Sohan, we went through this once already.
You can't reference the txt files like that. It's not
even in your web site folder. And that href doesn't
even reference your server once it's sent to the browser.

You create an ASPX page that will stream the text file
content. I already gave you the code for that. You reference
that ASPX file in the link, opening it in a new window, and
pass the text file name via a querystring, which you then
query and use in that ASPX file to stream.

It's either that or you need to put those text files in your
web site folder and reference them directly, using target="_blank"
in the link.

"sohan" <ka********@gmail.com> wrote in message
news:11**********************@v46g2000cwv.googlegr oups.com...
hi

I have hyperlink column in a datagrid. The column contains the name of
a text file.
I am able to appendthe full path of the file. The file is on D drive on
the server. But on clicking on that hyperlink does not open the file.
When I right click the link, I am able to save the file. I want the
file to be opne in browser in a new window.

I started a new webform and used a link
<a href='file:///D:/Test.txt' id ='hpl' runat='server'>test</a>
Even here it is not opening the text file. Is there any way to
hyperlink a text file in local disk on server and open it in a new
browser window

Can anybody help me out in this?

Thanks
Sohan

Mar 2 '06 #3

P: n/a
Thanks Raymond.

Mar 2 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.