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?

voluntaryist7
  • 115
  • 15

1 Answers1

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.

Community
  • 1
  • 1
Stephan
  • 666
  • 8
  • 23
  • 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. – voluntaryist7 Feb 21 '17 at 20:56
  • 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. – Stephan Feb 21 '17 at 21:47
  • Should I then omit using the bootstrap.css stylebundles in BundleConfig.cs file? – voluntaryist7 Feb 21 '17 at 21:52
  • 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. – Stephan Feb 23 '17 at 21:35