Hello Imar,
Is there a way to programmatically get all the Themes of a site? (I looked in the forum for this but I could not find it.)
For example I added a third theme called "Brown". I then added it to the dropDown ran the app and selected brown in the dropDown which created the cookie with my preferred theme. Then I closed the app deleted "Brown" from the dropDown and deleted the theme. So basically I decided to discontinue this theme. I still have brown in my preferredTheme cookie so I get an exception that says:
Theme 'Brown' cannot be found in the application or global theme directories. Is the "global theme directories collection" a collection I can get to? (I can't find it anywhere.) The only way I can do it is via a string array and if it is not in the collection set it to the Page.Theme and I'm sure there is a better way. In the stack trace there was:System.Web.UI.Page.InitializeThemes() I thought I could put my code there and just do a try catch if failed then set it to Page.Theme, but I can't get to it.
I'm not sure where execution goes after this point:
Code:
private void Page_PreInit(object sender, EventArgs e)
{
HttpCookie preferredTheme = Request.Cookies.Get("PreferredTheme");
if (preferredTheme != null)
{
Page.Theme = preferredTheme.Value;
}
}// Fails after leaving here
Thanks Imar