Click here to Skip to main content
14,449,842 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hi,
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!!
Posted
Comments
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?
Rate this:
Please Sign up or sign in to vote.

Solution 1

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.
Cheers.
   
Rate this:
Please Sign up or sign in to vote.

Solution 2

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

yourControl.Style.Add("PropertyName","PropertyValue");

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..
   

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100