This tutorial shows how to implement CSS StyleSheet usage with ASP.NET and how to change them dynamically. C# version.

This tutorial will show how easy it is to implement CSS stylesheets to an ASPX page, and also how to let the user dynamically change the look and feel of the website in an instant. In the example below, we use radio buttons to change between a light and a dark look to the website. This is done with two separate CSS files:

Two simple example CSS files are as follows.



To attach the StyleSheet, we add the following code inside the tags:

The ASPX code will look something like this.
Notice the radio buttons’ OnCheckedChanged attributes.

The code simply switches the StyleSheets upon radiobutton click. The code-behind should look something like this:

Download Source Files