May242008

Relative to Absolute Path

Published by Guillermo at 11:45 PM under Development

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




[KickIt] [Dzone] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Tags: , ,

E-mail | Permalink | Trackback | Post RSSRSS comment feed 0 Responses

Related posts

Add comment


(Will show your Gravatar icon)  

  Country flag

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]



Live preview


Response by on 1/7/2009 5:44:17 AM