Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > open text file in browser window using hyperlink

Reply
Thread Tools

open text file in browser window using hyperlink

 
 
sohan
Guest
Posts: n/a
 
      03-02-2006
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

 
Reply With Quote
 
 
 
 
Ward Bekker
Guest
Posts: n/a
 
      03-02-2006
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
 
Reply With Quote
 
 
 
 
Raymond
Guest
Posts: n/a
 
      03-02-2006
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) 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
>



 
Reply With Quote
 
sohan
Guest
Posts: n/a
 
      03-02-2006
Thanks Raymond.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Open new window using Javascript or Hyperlink =?Utf-8?B?SmF3YWhhcg==?= ASP .Net 3 11-19-2008 02:47 PM
Connecting to an open Window Example: IE Browser Window kbjohnson@gmail.com Java 1 11-14-2006 04:36 PM
Using asp:HyperLink to open a new window dana lees ASP .Net 8 04-20-2006 08:28 PM
How do I open a new normal (full sized) browser window form a small "pop-up" window? Shiperton Henethe HTML 17 05-21-2004 07:36 AM
Hot to open a page in a new window from a hyperlink of a crystal reports pdf file Daniel Geisenhoff ASP .Net 1 04-16-2004 06:29 AM



Advertisments