In the Page_PreInit method, where you assign topics, there are several ways to handle this. I am doing a check to make sure the directory exists. If so, then this is the topic I want. If this is not the case, use the default theme where I know the directory exists.
void Page_PreInit(object sender, EventArgs e) { if (ViewState["PageTheme"] == null) { if (!Directory.Exists("~/App_Themes/THEMENAME_TO_LOOK_FOR")) { Theme = "DEFAULT_THEME" } else { Theme = "THEMENAME_TO_LOOK_FOR"; } ViewState["PageTheme"] = Theme; } else { Theme = ViewState["PageTheme"].ToString(); } }
I usually store in a view, so I don’t need to double-check every time, but if you change themes on the fly, you probably don't need to do this.
James thomas
source share