It can be quite handy to use the ~ with ResolveUrl or for url properties of server controls, however, it does not work for ordinary markup, for instance:
<a href="~/Foo/Bar.aspx"></a>
would not work since you have to add the runat="server". You can work around this with the following if you happen to have access to Page:
<a href="<%=ResolveUrl("~/Foo/Bar.aspx") %>"></a>
But what if you do not have access to Page? Well, there is the option of rolling your own ResolveUrl, which is the approach I have taken many times.
I am still on a mission brushing up on my ASP.NET and found a community comment on the MSDN Docs for ASP.NET Web Site Paths that has a out-of-the-box way of doing this as follows:
<a href="<%=System.Web.VirtualPathUtility.ToAbsolute("~/Foo/Bar.aspx")%>"></a>
Very handy! and its been in since .NET 2.0 so it shows how much I am missing out on by not thumbing through the ASP.NET docs.
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.