CodePaste Logo
New Snippet New Snippet Recent Snippets Recent Snippets My Snippets My Snippets Web Code Search Snippets Search
Sign inor Register
Language: C#

ResolveThemeUrl

333 Views
Copy Code Show/Hide Line Numbers
/// <summary>
/// Returns an application Url that's Theme relative.
/// images/users.gif
/// returns: /myapp/app_themes/{activetheme}/images/users.gif
/// </summary>
public static string ResolveThemeUrl(string themeRelativePath)
{
    string theme = null;
    
    // try to pick up active theme
    Page page = HttpContext.Current.Handler as Page;
    if (page != null)
        theme = page.Theme;
    
    // if not available use config default
    if (!string.IsNullOrEmpty(theme))
        theme = App.Configuration.Theme;
                
    return HttpContext.Current.Request.ApplicationPath + "/".Replace("//", "") + "app_themes/" +
           theme +  "/" +
           themeRelativePath;
}
by Rick Strahl
  October 29, 2009 @ 2:04am
Tags:
Description:
Useful to embedding theme relative links to css and theme specific images. <%= ResolveThemeUrl("images/user.gif") %>.

Add a comment


Report Abuse
brought to you by:
West Wind Techologies



If you find this site useful and use it frequently please consider making a donation to support this free service.
Donate