Solved

How do I avoid encoding when using asp:hyerlink and the navigateurl property?

Posted on 2009-05-14
4
1,069 Views
Last Modified: 2012-05-07
I have a link in a database to a file on our network :
G:/Formatted CVs/FormattedCV_Ackerman_J_106485.doc
however when the link outputs to the browser it gets encoded to contain :
file:///G:/Formatted%2520CVs/FormattedCV_Ackerman_J_106485.doc
The %2520 stops the link working in IE7.  I can I prevent this encoding or should I use another control to output my hyperlink?

<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%#"file://" & Eval("ProformaLink").tostring %>'  Target="_blank">
<asp:Literal ID="Literal2" runat="server" Text='Link'/>
</asp:HyperLink>

Open in new window

0
Comment
Question by:dgloveruk
  • 2
4 Comments
 
LVL 14

Expert Comment

by:GiftsonDJohn
ID: 24383683
Try this

<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# Server.UrlDecode(string.Format("file://{0}", Eval("ProformaLink")))%>'  Target="_blank">
<asp:Literal ID="Literal2" runat="server" Text='Link'/>
</asp:HyperLink>
0
 

Author Comment

by:dgloveruk
ID: 24383824
Nope, sadly this generated the same link and the same problem.
Any other ideas?
0
 
LVL 12

Accepted Solution

by:
GuitarRich earned 500 total points
ID: 24383856
the NavigateUrl property will UrlEncode the data going into it - can you change it to a standard hyperlink?
<a href='<%#"file://" & Eval("ProformaLink").tostring %>'  Target="_blank">
<asp:Literal ID="Literal2" runat="server" Text='Link'/>
</a>

Open in new window

0
 

Author Closing Comment

by:dgloveruk
ID: 31581391
That did the trick, I had a go at this before but wasn't able to get a syntax it was happy with, cheers!
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question