Link to home
Start Free TrialLog in
Avatar of David Glover
David GloverFlag for United Kingdom of Great Britain and Northern Ireland

asked on

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

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

Avatar of GiftsonDJohn
GiftsonDJohn
Flag of India image

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>
Avatar of David Glover

ASKER

Nope, sadly this generated the same link and the same problem.
Any other ideas?
ASKER CERTIFIED SOLUTION
Avatar of GuitarRich
GuitarRich
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
That did the trick, I had a go at this before but wasn't able to get a syntax it was happy with, cheers!