You have (at least) two ways to achieve this:
- From within a Control, use Control.ResolveURL.
public class URLHelper
{
public static string GetAbsoluteURL(string relativeURLPath)
{
return VirtualPathUtility.ToAbsolute(relativeURLPath);
}
}
- From anywhere else where you don't have access to the control object: use the System.Web.VirtualPathUtility helper class' ToAbsolute(url) method.
// A Property of your control //
...
public string AbsoluteURL
{
get
{
return this.ResolveUrl();
}
}
...