Last post Feb 26, 2009 06:20 AM by babuji_godem
May 04, 2007 10:07 PM|mandercruso|LINK
I have multiple master pages and I was wonder how do you dynamically change the theme for the entire site upon user selection (dropdownlist).
Ex. I have template.master which is only used for the default.aspx page. I have subtemplate.master for all subsequent pages. The dropdownlist for theme selection is on the default.aspx page.
My web.config has this line of code assigning the default template:
When I try to put the code for changing the theme on the preinit of default.aspx, it only changes the theme of the default.aspx page and none of the others (which use a different master page).
Any help is appreciated.
May 04, 2007 11:12 PM|AsinuS|LINK
U can try the method descibed here (http://www.codeproject.com/useritems/dynamicThemes.asp).
Make a base page and let all of your other pages inherit that one. Hope that does the trick for ya.
May 04, 2007 11:23 PM|himawari|LINK
You will have to find a way to persist the theme selection across pages.
I will recommend you create a PageBase class inherite from the Page class, and have all your pages in your site inherited from this PageBase class.
In the PreIn of your PageBase class, can use a cookie, session state or other logic to store the theme selection. My following example, in C#, assumes that you have a cookie set for the desired theme.
protected override void OnPreInit(EventArgs e)
if (Request.Cookies["theme"] != null)
this.Theme = Request.Cookies["theme"].Value;
Theme Dynamically Changing a theme
May 05, 2007 09:42 AM|Sergey Egorov|LINK
May 07, 2007 09:50 PM|mandercruso|LINK
Thanks for your response. I found your similar response to another question here:
http://forums.asp.net/thread/1649475.aspx. I don't program using C#, only VB... can you "translate" this for me? I've tried but can't seem to figure it out. Thanks!
May 08, 2007 11:14 AM|Zhao Ji Ma - MSFT|LINK
May 08, 2007 01:56 PM|ausideveloper|LINK
If you want to persist a theme, the best way (I think) is to use the asp.net personalization Profile which caters for Anynomouse users.
Feb 26, 2009 06:20 AM|babuji_godem|LINK
You can write a method (which overrides the Style Sheet) in a class file which is inherited by all the content page.
Here is a good example, you try it