Click here to Skip to main content
15,935,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a requirement to read a css file and find a particular class of this css file and then change the property value(say:color) of the class and save it back to css file using code behind in C#.
Can anybody help me!!
Timberbird 2-Nov-12 9:34am    
If you need to change element's style it's bad solution, but I guess these are the requirements you have. Well then, what do you have trouble with: action logic or implementation?

1) Who has given you this as a "requirement", because whoever did that doesn't really know how things work. It is a silly idea. If the css is to be updated, it should be done in a text editor by a developer or designer and that's that.
2) If the idea is to provide a user the ability to customize their experience on your site, then overwriting the css is NOT the way to go. If you overwrite the css, it will affect all users and not just the one making the changes. If this is the case, you are better off to provide a custom configuration database which will store all the configurable values after which you can write a manager class to generate the css dynamically for each user based on their preferences.
3) If I'm totally off base with what you are trying to ask, please use the Improve Question widget to expand on your query.
Share this answer
I think you've mistake in understanding requirement...

If you change in existing class property, this will affects entire web site..

Even though you want minor change in cs file then you can use


If want entire entire class then use

yourControl.CssClass = "yourClassName";

If you want to store all style user wise then its better to store style in database..
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