I have an aspx page with a ListView on it being populated from a database. A dropdown is at the top of the page and the user can select which client to view. Each client has different colors for text and borders and such. I have a stylesheet for every cleint, but in the css classes, I'm only changing 3 things and the rest stays the same.
.grid
{
border: solid 2px #000; /** this changes **/
font-family: Tahoma;
font-size: 12px;
width: 700px;
background-color: #fff;
margin: 0px auto;
position: relative;
margin-top: 50px;
padding-bottom: 5px;
}
.grid H2
{
background: #8988a5 url(../images/sgtitle-bg.gif); /** this changes **/
border-bottom: solid 1px #000; /** this changes **/
height: 28px;
line-height: 28px;
margin: 0px;
padding: 0px 0px 0px 5px;
color: #000;
font-size: 15px;
}
We have over 40 clients coming and it's ridiculous to have over 40 style sheets when only 3 lines are changing. How do I modify or create css classes in C#? This is .NET 4.0
<%@ Page Language="C#" %>
<%
string color = "blue";
%>
H1 { background-color:<%= color %>; }
Then reference that file in your other pages just like you would any other css file.
<link type='text/css' rel='stylesheet' href='../myCSS.aspx' />