Last post Apr 30, 2009 04:40 AM by WereWolf
Apr 27, 2009 04:38 PM|PProgrammer|LINK
VS 2008, .NET 3.5, C#, webapplication
Changing the theme at runtime is possible during page_PreInit.
I need to change the theme after the user has clicked a button.
But the theme changes only after the button was clicked AND a browser-refresh in addition.
How can I change the theme with ONLY one button click?
Thanks for your hint.
Apr 27, 2009 05:30 PM|WereWolf|LINK
you could simply redirect the user to the same page after setting the theme.
You change-theme-button click event handler would look like this:
Apr 29, 2009 09:30 AM|PProgrammer|LINK
Your code does what I want, thanks a lot.
Apr 29, 2009 09:47 AM|WereWolf|LINK
[:)] Glad i could help!
Apr 30, 2009 03:15 AM|PProgrammer|LINK
I needed to move your code into the MasterPage.
The second code part does not work anymore:
Compiler Error Message: CS0115: 'MasterPages_MasterPage1.OnPreInit(System.EventArgs)': no suitable method found to override
I saw in the web, that MasterPages don't have a PreInit-Event.
Have you got an idea, how to fix the problem?
Apr 30, 2009 04:40 AM|WereWolf|LINK
Theme can be changed on the Page only in PreInit event (or before).
The MasterPage does not have a PreInit event, but maybe I've found a workaround, overriding the FrameworkInitialize() method:
if (Session["theme"] !=
Page.Theme = Session["theme"].ToString();
Hope it helps. Bye!