Solved

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

Posted on 2009-05-14
4
1,091 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

732 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