title: ASP.NET: Creating a CSS class programmatically
body: <p>I have a web control that I would like to modify the CSS class under certain conditions.</p>
  
  <p>Ideally, I would like to write something like:</p>
  
  <p>myMenu.StaticMenuItemStyle.CssClass = (".bgColor", "{background:#ff0000}");</p>
  
  <p>Unfortunately, this is a third party control, and it does not expose any Style or Attribute properties. The only property exposed is CssClass. The problem is that the hex color is retrieved from the database, so I cannot have it predefined ahead of time in a css file.</p>
  
  <p><strong>EDIT:</strong> I don't know the HEX value to use for the background until OnPreRender() where I fetch the HEX value from the DB. At this point, I need to create/modify a css class by inserting/updating the HEX value for the background.</p>
  
  <p>How can I programmatically create and assign a css class?</p>