Click here to Skip to main content
15,921,837 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Actually I want to change color code using dynamic.
string strNewCode ="#FFF";

string strOldCode = "#fbb";

so i want to change in css file strOldCode to strNewCode.

What I have tried:

Actually I want to change color code using dynamic.
string strNewCode ="#FFF";

string strOldCode = "#fbb";

so i want to change in css file strOldCode to strNewCode.
Posted
Updated 14-Jul-16 23:11pm
Comments
F-ES Sitecore 15-Jul-16 4:27am    
There's probably a better way of doing what you want. You can't (shouldn't) change css files, instead you define two classes, one for each colour you want and you change the html markup of the particular element to have the class that matches the colour you want it to be.

It is best that you define separate classes in your CSS, and
then change HTML markup.

HTML
#header h1 {
			position: absolute;
			z-index: 1;
			width: 100%;
			top: 100px;
			left: 0;
			font-size: 3.3em;
			color: #fff;
			text-align: center;
			letter-spacing: -2px;
		}

#header h2 {
			position: absolute;
			z-index: 1;
			width: 100%;
			top: 100px;
			left: 0;
			font-size: 2.3em;
			color: #fbb;
			text-align: center;
			letter-spacing: -2px;
		}
 
Share this answer
 
C#
string hex = "#FFFFFF";
Color _color = System.Drawing.ColorTranslator.FromHtml(hex);
 
Share this answer
 
C#
object.CssClass= object.CssClass.Replace("OldClass", "NewClass");
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900