Link to home
Start Free TrialLog in
Avatar of GlobaLevel
GlobaLevelFlag for United States of America

asked on

vb.net - How do I add css to a web user control?

I have a web User control and I am curious how one adds CSS to it....everything I have tried, doesnt seem to work...
ASKER CERTIFIED SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
As a tangible example, let's say I have a page that made use of a stylesheet which had the following class:

.thisIsBlue
{
    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.
P.S.

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  = )
Avatar of GlobaLevel

ASKER

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...
And the page hosting the UC has the appropriate stylesheet imported?