views:

59

answers:

2

Hello, I have a situation where my H3 tags are styled in an external CSS file, but the color attribute is going to dynamically change based on a database value. I would like to inject some CSS into my master page from code-behind to set the color of the H3 tag globally instead of having to specify it on each tag.

How can I do this? Thanks!

+2  A: 

try the !important css attribute

Michele
My question was specific to adding the dynamic css value. I solved it and will post the answer.
Mike C.
Ah, I see what you are getting at now. Good note. Luckily I just removed the color element from my static CSS file so I didn't have this issue.
Mike C.
A: 

I didn't realize I could put controls in the style section. Here's how I resolved the problem:

<style>
   h3 
   {
      color:<asp:Literal runat="server" id="ColorLiteral" />;
   }
</style>

Now I set the literal from code-behind and it works great.

Mike C.