Am trying to implement the beerhouse CMS (ASP.NET 2.0 Website Programming: Problem - Design - Solution), I face a problem in the second chapter, while implementing the themes.
The problem here is even when I select white as the theme it remains as default, though the postback happens, it remains a white. I have also applied the breakpoint, here this.Page.Theme is always white.
Can anyone help me with finding out where the problem lies.
The themes are called from the helper class
//This is the helper class
public static string[] GetThemes()
{
if (HttpContext.Current.Cache["SiteThemes"] != null)
{
return (string[])HttpContext.Current.Cache["SiteThemes"];
}
else
{
string themesDirPath = HttpContext.Current.Server.MapPath("~/App_Themes");
// get the array of themes folders under /app_themes
string[] themes = Directory.GetDirectories(themesDirPath);
for (int i = 0; i <= themes.Length - 1; i++)
themes[i] = Path.GetFileName(themes[i]);
// cache the array with a dependency to the folder
CacheDependency dep = new CacheDependency(themesDirPath);
HttpContext.Current.Cache.Insert("SiteThemes", themes, dep);
return themes;
}
}
And the dropdownlist is binded to the helper class through a user control
protected void Page_Load(object sender, EventArgs e)
{
if (Globals.ThemesSelectorID.Length == 0)
Globals.ThemesSelectorID = ddlThemes.UniqueID;
ddlThemes.DataSource = Helpers.GetThemes();
ddlThemes.DataBind();
ddlThemes.SelectedValue = this.Page.Theme;
}
I have designed to themes, one is default and the other one is white, and declared it in the pages section in
web.config.
<pages theme="Default" masterPageFile="~/MyCMSMaster.master">