Solved - How do I add css to a web user control?

Posted on 2011-10-12
Last Modified: 2012-05-12
I have a web User control and I am curious how one adds CSS to it....everything I have tried, doesnt seem to work...
Question by:GlobaLevel
    LVL 74

    Accepted Solution

    What do you mean by adding CSS to it? If you use it on another page, it gets turned into markup that is displayed within that page, so it will effectively inherit whatever CSS the page is using.
    LVL 74

    Expert Comment

    by:käµfm³d 👽
    As a tangible example, let's say I have a page that made use of a stylesheet which had the following class:

        color: blue;

    Open in new window

    Let's also say that I have a UserControl that has a Label, and this label has its CssClass set to "thisIsBlue"; I also insert an instance of the UC into the page's designer. Since the UC will be turned into markup that is inserted within the markup of the page, when the page is rendered, the Label's rendered text will be displayed in blue.
    LVL 74

    Expert Comment

    by:käµfm³d 👽

    You won't be able to see this effect in the VS designer for the UC. There may be a way to specify the stylesheet the UC will use in the end (for testing purposes), but I am not certain--not that I've looked incredibly hard for it. I usually just try running the page to see the output  = )
    LVL 10

    Author Comment

    Hi Kaufmed,

    I add CssClass="format_controls" to all the controls including the UC...but at runtime all the controls format correctly except the UC, which I found weird...the CSS didnt impact it at all...
    LVL 74

    Expert Comment

    by:käµfm³d 👽
    And the page hosting the UC has the appropriate stylesheet imported?

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (…
    Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now