I have an AppSettings key for a specific color that my company uses and I want to apply that color to a CSS class. It is important that it uses the key, because other companies may want to change the color to their own. My problem is that I cannot figure out how to apply my key in my stylesheet. Is there any way to call the ConfigurationManager in a .css file or is there some kind of workaround?
Web.config with keys:
<appSettings>
<add key="webpages:Version" value="3.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
<add key="CorpColorBlue" value="#004B85"/>
<add key="CorpColorGreen" value="#009467"/>
<add key="CorpColorOrange" value="#E98300"/>
</appSettings>
CSS Class I am trying to apply it to (brackets are for clarification):
.thead-company {
color: white;
background-color: [COMPANY-BLUE];
border-color: [COMPANY-BLUE];
}
My current solution is to just call the ConfigurationManager directly in my views, but that is too much duplicated code and will be an issue when a color is changed. What can I do instead?
Current solution:
...
@{
var companyBlue = ConfigurationManager.AppSettings["CorpColorBlue"];
}
...
<table class="table table-hover table-bordered table-striped">
<thead class="thead-company" style="background-color:@companyBlue; border-color:@companyBlue">
...