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

Posted on 2011-10-12
Medium Priority
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
  • 4
LVL 75

Accepted Solution

käµfm³d   👽 earned 2000 total points
ID: 36958873
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 75

Expert Comment

by:käµfm³d 👽
ID: 36958887
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 75

Expert Comment

by:käµfm³d 👽
ID: 36958899

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

ID: 36962019
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 75

Expert Comment

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

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses
Course of the Month13 days, 12 hours left to enroll

755 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