473,320 Members | 2,180 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

using css in a user control

How do you use css in a user control? I need to put the css in a stylesheet
outside of the control.

Sep 22 '08 #1
2 1600
Your user control's output is destined to be included in-line with HTML in
the rendered page, so it's OK to add attributes to your controls to refer to
CSS classes, id, etc. so long as the CSS style sheet loaded by the page has
corresponding classes, ids etc., all will be sweet.

You're not thinking of adding a stylesheet link <link
href="../css/General.css" rel="stylesheet" type="text/css" /as part of
your user control content are you? That's not going to work (well, some
browsers may accept this kind of sloppy practice but flags should be raised
about breaking W3C standards compliance). If the rules you need are not in
the page's stylesheet you *could* add some code in the control's load event
to add an additional styelsheet link to the <headof the containing page,
but I suspect that's more effort than you're aiming for.

"Andy B" <a_*****@sbcglobal.netwrote in message
news:%2***************@TK2MSFTNGP06.phx.gbl...
How do you use css in a user control? I need to put the css in a
stylesheet outside of the control.

Sep 22 '08 #2
"Your user control's output is destined to be included in-line with HTML in
the rendered page, so it's OK to add attributes to your controls to refer to
CSS classes, id, etc. so long as the CSS style sheet loaded by the page has
corresponding classes, ids etc., all will be sweet."

That is more the less what I was thinking of.

"You're not thinking of adding a stylesheet link <link
href="../css/General.css" rel="stylesheet" type="text/css" /as part of
your user control content are you?"
Nope. wouldn't work anyways. Tried it in an experiment when I first started
with asp.net and figured out it doesn't work.

"That's not going to work (well, some browsers may accept this kind of
sloppy practice but flags should be raised about breaking W3C standards
compliance). If the rules you need are not in the page's stylesheet you
*could* add some code in the control's load event to add an additional
styelsheet link to the <headof the containing page, but I suspect that's
more effort than you're aiming for."

Maybe. I have a control that I will be making. It is a news control that
will get news from the database and show the articles on the page it is put
on. It will have ajax in it since I want to show the whole news article
without having to reload the whole page. It will have a property where you
can choose how many articles titles are displayed for that instance since I
plan on using it twice on the site. Once on the homepage and another time on
the news page. The homepage version shows 3 titles by default and the one on
the news page shows all titles. I was thinking of possibly having a content
block like the ones used in master pages for the stylesheets needed for each
particular page they are used on, but am wondering if the control load event
thing might be easier?

Sep 22 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Random Person | last post by:
Does anyone know how to use VBA to relink tables between two MS Access databases? We have two databases, one with VBA code and the other with data tables. The tables are referenced by linked...
19
by: James Fortune | last post by:
I have a lot of respect for David Fenton and Allen Browne, but I don't understand why people who know how to write code to completely replace a front end do not write something that will automate...
1
by: Daveyk0 | last post by:
Hello there, I have a front end database that I have recently made very many changes to to allow off-line use. I keep copies of the databases on my hard drive and link to them rather than the...
11
by: Lloyd Sheen | last post by:
Is there any one who has actually done this. I have now scanned more web articles about this with the realization that not one of them (including MSDN docs) outlines how to do this. This is...
5
by: Marcel Gelijk | last post by:
Hi, I am trying to create a User Control that is located in a seperate class library. The User Control contains a textbox and a button. The page generates an exception when it tries to access...
10
by: George G. | last post by:
Hi there, I am busy writing a new asp.net application and I am reusing some of my existing asp functions and methods in a user control. I need access to session, request and response in some of...
15
by: Nathan | last post by:
I have an aspx page with a data grid, some textboxes, and an update button. This page also has one html input element with type=file (not inside the data grid and runat=server). The update...
2
by: Hans Merkl | last post by:
Hi, I am trying to use a user control as EditItemTemplate in a DataList. It loads fine but I can't figure out how to bind to the data of the DataList. Here is what I have got so far: ...
0
by: tony | last post by:
Hello! I have one solution file that consist of three project. One project that build the exe file called A One project that build a user control dll. In this user control we have a class...
5
by: Guy Noir | last post by:
I have a quick question on custom controls. I have a control that I created with a class that extends the NumericUpDown control. My problem is that when I use this usercontrol on my form, the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.