I’m learning ASP.net and I’ve been playing around with themes and master pages. I decided I wanted to change the theme of the website, and used the web.config solution (adding theme to web.config). What I want to do now is to be able to change the theme based on user and the selected theme by the user.
I have been unable to find any tutorials, all of them seem to show how to change separate contentpages, but I want to change the whole site theme.
How do you go about doing that, in the simplest way? I am not connected to a database atm., it’s just for practice 🙂
with kind regards
Create a base page that you inherit all your pages from and set the theme in the OnPreInit event:
Below is the ThemeSwitcher utility class that handles getting/saving the current theme and listing themes. Since you said you’re not using a database you can use Session:
You’ll want a page where you can change the theme. Add a dropdownlist with the following code behind:
You can download the sample application here.