A A
RSS

Resolving URL in ASP.net using Tilda (~)

Fri, Jan 5, 2007

Uncategorized

I have been using .net since it has come out and I just found this out (so, I am kind of pissed). When I wanted to link to another url in my site e.g. <a href=”~/folder/file.aspx”>click here</a> it never worked because the <a> tag doesn’t understand the tilde (~). The way I used to fix this is by adding the runat=server to the <a> tag which enables it to understand what it means.

I just found a better solution – using ResolveClientUrl and it looks like this:

<a
href=’<%= ResolveClientUrl(“~/folder/file.aspx”) %>
/>

Tags:

  • Or just type click here. The runat-command will make asp.net to resolve the url.
  • but that will make the link postback instead of being just a regular link.
  • Korayem
    Nice find!
blog comments powered by Disqus
Advertise Here

What I'm Doing...

Yonkly Open Source

Sign up for my newsletter

powered by MailChimp!

Cyber Identity