Solved

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

Posted on 2009-05-14
4
1,057 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

744 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now