473,805 Members | 1,995 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1320
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@newsfe 6-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
2172
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 will follow. May no new grief divide us."
5
2982
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 separately. The control panel is basically (almost) fully self contained. It consists of a tabbed pane with 5 different tabs. Each tab has a number of different controls -- basically all the "commonly used" controls (buttons, lists, comboboxes,...
6
2706
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 http://www.lebans.com/DownloadFiles/A2kTooltip.zip So far the classes work perfectly, except that now I need to extend it to support other controls besides the ones given in the example form. I have gotten it to work with some controls, but not others. I...
6
1871
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 the box/label combination to act as a single item when clicked - that is, not have to put the same OnClick code on both the box and the label (or force the user to click on the background only). I've tried attaching the label to the box (by...
3
1425
by: toki | last post by:
public class Form1 : System.Windows.Forms.Form { MyClass myclass; public Form1() { myclass = new MyClass(); } }
1
1305
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 information has been keyed into them. Is there a way to do that? How do I reference other controls in my JavaScript? Thanks in advance for your assistance!!!!!!!!!
3
1381
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 case it would be deleting a record. For buttons that are placed on page at design time, I can use Add.Attributes to achieve the above. However, controls in Reapeater are created at runtime. How do I do this?
5
4548
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 control that has 2 or 3 events selectionChanged DropDownOpened I would like the user to be able to attach Server Side events for both. I have the client side implementation worked out. I just need to find a proper way to to get everything...
0
1166
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 attach style sheet to my user controls like: <link href="../App_Themes/DefaultSkin/Main.css" rel="stylesheet" type="text/css" />
0
9716
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9596
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10359
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10104
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9182
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6875
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4317
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3843
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.