1

I have Hyperlink in a datalist. HTML is given below:

<asp:HyperLink ID="lnkEntry" runat="server"><%# DataBinder.Eval(Container.DataItem, "Title") %></asp:HyperLink>

i have saved the URL of a Entry in the Database, like "http://test.com/posts/New-test-in-March" And used the following way to Bind it to Hyperlink in Item_databound of Datalist.

 lnkEntry.NavigateUrl = objEntry.PermaLink;

But when it renders into the browser the URL get changed to "http%3a//test.com/posts/New-test-in-March"

i have tried to use the URLDecode but it doesn't make any change in output.

 lnkEntry.NavigateUrl = Server.UrlDecode(objEntry.PermaLink);

Please help me how can i fix this issue.

Ram Singh
  • 6,664
  • 35
  • 100
  • 166

1 Answers1

0

you should use HttpUtility, like this:

 lnkEntry.NavigateUrl = HttpUtility.UrlEncode(objEntry.PermaLink);

or WebUtility if running recent versions of .net.

Check this thread for more info.

Community
  • 1
  • 1
U r s u s
  • 6,680
  • 12
  • 50
  • 88