Get Current Theme Programmatically
Posted by Tihomir Ivanov on 12 November 2009 16:40
Rating: 0.00
Sometimes it's necessary to get the current Theme Name and it's physical folder path (ex. to check if some file exists in the current theme folder).
We usually define the corrent theme in the WebConfig File:
...
<pages theme="Default" ... >
...
Now, how we could get the current theme name programmatically (C# example):
using System.Web.Configuration;
...
PagesSection pageSection = ConfigurationManager.GetSection("system.web/pages") as PagesSection;
//t pageSection contains property Theme with value - the name of the current Theme
string currentTheme = pageSection.Theme;
//t now we could get the current theme folder physical path
string themeDirPhysicalPath = HttpContext.Current.Server.MapPath("~/App_Themes/" + pageSection.Theme);
...
well, that seems to be All :)
Comments:
No comments yet.