473,396 Members | 1,871 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,396 software developers and data experts.

Attaching CSS classes to web controls

wh
This is more a question of style really, nothing too technical - honest.

My question is what is the preferred way of defining the styles of elements
in an asp.net page?

Supposing I have several *Web* controls (i.e. <asp:label> elements) that I
want to apply a formatting style to. The first method would be to select all
controls in page design view then set the appearance properties in the
properties window. The other method would be to set the CssClass property of
each control then create a new css class in a stylesheet and attach this to
the page.

Personally, I tend to stick with the second method though I was wondering
how much we should know about the underlying html that is generated.
Supposing I have an <asp:label> element. This is rendered as a <SPAN>
element, so in my stylesheet I have the following rule:

SPAN.MyLabel
{
/* define style here */
}

May we always assume that <asp:label> elements get rendered as <span>
elements. I know an alternative would be to not supply the SPAN element
declaration in the css rule and just have:

.MyLabel
{
}

but I prefer to supply as much information as possible to the browser that
reads the stylesheet.

Wayne.
Nov 18 '05 #1
1 1305
I think it should be evident that a label will always be rendered
as a span element as a label is not a container nor a collection
of objects.
--
<%= Clinton Gallagher
A/E/C Consulting, Web Design, e-Commerce Software Development
Wauwatosa, Milwaukee County, Wisconsin USA
NET csgallagher@ REMOVETHISTEXT metromilwaukee.com
URL http://www.metromilwaukee.com/clintongallagher/



"wh" <wa***@no-spam.pyesmeadow.com> wrote in message
news:mnVBc.1379$I43.828@newsfe6-win...
This is more a question of style really, nothing too technical - honest.

My question is what is the preferred way of defining the styles of elements
in an asp.net page?

Supposing I have several *Web* controls (i.e. <asp:label> elements) that I
want to apply a formatting style to. The first method would be to select all
controls in page design view then set the appearance properties in the
properties window. The other method would be to set the CssClass property of
each control then create a new css class in a stylesheet and attach this to
the page.

Personally, I tend to stick with the second method though I was wondering
how much we should know about the underlying html that is generated.
Supposing I have an <asp:label> element. This is rendered as a <SPAN>
element, so in my stylesheet I have the following rule:

SPAN.MyLabel
{
/* define style here */
}

May we always assume that <asp:label> elements get rendered as <span>
elements. I know an alternative would be to not supply the SPAN element
declaration in the css rule and just have:

.MyLabel
{
}

but I prefer to supply as much information as possible to the browser that
reads the stylesheet.

Wayne.

Nov 18 '05 #2

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

Similar topics

6
by: .: DeVa :. | last post by:
How can i brows for picture on disk and then save it into array for mailing ? ------ www.podvodni-svijet.com "Half-brother in blood, full brother in heart will I be. Thou shalt lead and I...
5
by: Hal Vaughan | last post by:
I think a lot of this is definately a question of personal programming style, but I'm new to Java and would like to hear a few opinions. I'm writing a control panel for an application that runs...
6
by: Robert | last post by:
Hello. I have been trying out the Lebans ToolTip Classes at http://www.lebans.com/tooltip.htm, to display "balloon" style help tips in a form. The classes I am using are located at...
6
by: Armando | last post by:
Hey gurus - Access 2000 - I have a form with a series of box controls forming a map of clickable areas, and I want each one to have a label. No problem, just put 'em on, right? But I also want...
3
by: toki | last post by:
public class Form1 : System.Windows.Forms.Form { MyClass myclass; public Form1() { myclass = new MyClass(); } }
1
by: Jim Heavey | last post by:
Hello, I was wondering how I would go about attaching some Java script code to a <asp:EditCommandColumn. If the user presses the "edit" link, then I want to test other controls to see if any...
3
by: Charlie | last post by:
Hi: I would like to attach client side code to an imagebutton that is rendered in a Reapeater control. The client code will simply confirm if users wants to continue with an operation. In this...
5
by: | last post by:
I am wondering what the best method of attaching custom Events to custom WebUserControls are. I cannot seem to find the proper terminology to expand my research. Basicallly I have a custom user...
0
by: Med | last post by:
Hi, Since my upgrade from VWD2005 to 2008, I am getting lots of 'The class or CssClass value is not defined.' warnings for my css classes in UserControls only! To avoid these warning, I can...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.