tags:

views:

26

answers:

1

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">
A: 

Have you created the custom base class for your page? This is where the code lives that actually changes the Theme (this.Theme = this.Request.Form[id];).

Once you create the custom base class you'll need to change the Default.aspx to use the new BasePage class :-

public partial class _Default : MB.TheBeerHouse.UI.BasePage
{
   protected void Page_Load(object sender, EventArgs e)
   { }
}

If you need to you can download the source code to check against yours from http://www.wrox.com/WileyCDA/WroxTitle/productCd-0764584642,descCd-DOWNLOAD.html

Andy Robinson