Tags: , , | Categories: Development Posted by Guillermo on 5/24/2008 11:45 PM | Comments (0)

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();
    }
} 
...
  



kick it on DotNetKicks.com