Relative to Absolute Path

by Guillermo 24. May 2008 23:45

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


Tags: , ,

Development

Powered by BlogEngine.NET 1.5.0.7
Theme by Extensive SEO

About the author

Something about the author

Your Most Recent Comments

Comment RSS

Page List