Is it possible to edit or modify css
file at run time?
It is possible, but it's not advisable. What you're proposing is to make your asp.net application into a file editor. That would involve raising the privileges for your application's security context (the user under which it runs) which opens a big can of worms.
The simplest alternative is to inject classes into your asp.net page by writing a new <style type="text/css">
element to your page that includes the css classes you want to produce dynamically.
For example, you might save the background-color
to a UserSettings
table (or any other per-user persistence mechanism), then load it into your .aspx page like this:
<style type="text/css">
.changebackgroundcolor {
background-color: <%= user.BackgroundColor %>;
}
</style>
Or you could keep the class definitions in a css file. Instead of emitting the classes directly into the page, dynamically write some jQuery code to change the definition of the class, following some of the examples from other answers.