Reputation: 41
I have a webform and I want to create a hyperlink to a text file, so that it opens on internet explorer in a new window. I have added the following
<a href="file:///D:/Test/Test.txt" id="hplTest" runat="server">testhyperlink</a>
Now when I click on the hyperlink, nothing is happening. No error.
when I open a browser and type file:///D:/Test/Test.txt
, the file is opening.
I would appreciate if anybody could help me out.
Upvotes: 1
Views: 2493
Reputation: 148110
You can not give physical path in href with file://
, give the url instead.
<a href="http://www.yourdomain.com/Test/Test.txt" id="hplTest" runat="server">testhyperlink</a>
If the file is within current site then use relative path.
<a href="~/Test/Test.txt" id="hplTest" runat="server">testhyperlink</a>
The ~ here is for root path.
Upvotes: 1
Reputation: 17614
The physical path is wrong in your example.
Either you can use absolute path
<a href="http://myDomain/folder/Test.txt" id="hplTest" runat="server">testhyperlink</a>
Or you can use the relative path
<a href="~/Test.txt" id="hplTest" runat="server">testhyperlink</a>
You can also use target
on anchor tag if you want to open it in a new window
<a href="~/Test.txt" id="hplTest" runat="server" target="_blank">testhyperlink</a>
More target Detail Link of MSDN
Upvotes: 0