0

I am using a dark themed (Cyborg, to be exact) bootstrap.css file from Bootswatch in my ASP.NET Web Forms application. My plan is to give users the ability to change this theme to be customized upon their login. For example, if user Joe likes the dark theme, he can leave his set to default (dark). However, if Bob likes a light grey theme, he can go into his user settings page and select "light" which would then load the site with a light-colored bootstrap.css theme (like lumen).

So how can I do this? I know this is set in BundleConfig.cs, which is in App_Start and gets registered on Application_Start in Global.asax. Is there a way I can change this on a page load event as well?

0

1 Answer 1

1

It can be done through javascript as part of an event listener on a button. Take a look at this question which is similar.

Sign up to request clarification or add additional context in comments.

4 Comments

The second answer (by user "sam") works very well, but will I have to do this for every page? The benefit of using boostrap the way Visual Studio implements it now is to keep things smooth and consistent.
You should add it only to the template which houses your navigation bar, so it is in one place, and always available. When i built one, we had a small button in the footer that allowed them to change from day to night view, which flipped the css and changed the icon on the button.
Should I then omit using the bootstrap.css stylebundles in BundleConfig.cs file?
I havent used stylebundles, so i cant help you there. if it seems like its getting in the way, you might disable it, but I'd leave it be for now. I would think the example above would swap it on the client directly, so as long as the file is reachable on the server, id think itd be fine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.