How do I add CSS styles to an ASP.NET UserControl from the code-behind?

Tags: c#,.net,,css

Problem :

this.Style.Add ( /*...*/ )

... doesn't appear to work.

What do I need to do to add a style to it?

Solution :

Think about the nature of UserControl - it's intended to contain other ASP.NET controls and that's why you cannot set CSS for whole control.. instead you just need to specify styles for each child control individually. You can also take a look at the ApplyStyleSheetSkin method.

    CSS Howto..

    How do I set the width of inputs within a column in Twitter Bootstrap's grid system?

    How can I stop an image element from taking 100% width?

    How to show/hide a 3 levels menu nav in css?

    How can I get IE8 to accept a css :before tag?

    How to Stop Overriding of Bootstrap Css Styles

    Show DIV on hover of other DIV that is not parent with CSS or JS [duplicate]

    how to remove some css attributes defined by bootstrap

    How to center images vertically these divs?

    How to use one icon from different image files?

    How to get maximum compatibility with most of the devices for a Mobile Website?

    How to remove floats so items don't wrap with CSS only in this Codepen

    HTML/CSS: How do I make an input field with 2 vertically positioned buttons next to it?

    How to solve this HTML/CSS bug? [closed]

    How can I make a smooth transition of my input's placeholder text?

    How can I modify my CSS to require a class instead of a “+ label”?

    How to display first tab by default in css?

    How to add a margin to a paragraph?

    How come the links in my footer section remain purple and underlined even when I use CSS to change that

    How to animate a rotated DOM element with CSS

    How do I displaying a list of multiple objects, one below the other, in HTML using Django?

    How to position a background image like

    How can i apply css rules dynamically in a div after the user enters the rules [closed]

    How can I show a element on my site when hovered with only JS?

    how to achieve this effect with css html?

    How to fix image loading time with my image slider?

    How to change the content value of iconmoon font?

    How to make this css readable?

    Show the menu at the center of the data toggle

    How can I make my CSS code compatible with all browsers? [closed]

    How to re-size constantly changing text to fit in a div with a fixed width, based on the changing of a