open text file in browser window using hyperlink

S

sohan

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
 
R

Raymond

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top