01 November 2005 20:58
, .NET 2.0
A while back I blogged about a skinnable script control to provide access to theme-specific script includes. Well, after some recent testing I realised that it wasn't generating urls that worked in all circumstances.
Most of the ASP.NET Web Controls (such as the Image control) allow you to specify a URL as being application root relative by using the tilde character '~'. After a little digging in to the source code using Reflector I quickly saw that using base.ResolveUrl (from the System.Web.UI.Control) is what controls like Image use, so a quick change to the render code means I can put a tilde at the start of the script location and pass it to base.ResolveUrl to generate a script location that works all the time because it's relative to the root of the application.