473,320 Members | 2,177 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.

How to assign CSS element to ASP.NET namespace

I want to use a css element and apply it to all labels on a page with the
"asp:label" tag.

I defined a CSS class:

..cls1
{
font-weight: bold;
color: royalblue;
font-family: Verdana;
}

and then can assign to the control using the CssClass property:

<asp:label id="Label1" style="Z-INDEX: 101; LEFT: 335px; POSITION: absolute;
TOP: 69px" runat="server"
CssClass="cls1" Height="42px" Width="210px">Label</asp:label>

However, this is a pain to have to manually assign to each label control. I
want to define one CSS element that maps to "asp:label"
and have it apply to all label controls w/o having to explicitly assign the
CssClass. Is there a way to do this?

Thanks!
Leor

Nov 19 '05 #1
4 1909
Leor,

An asp:label renders as a <span>. You can try

span
{
font-weight: bold;
color: royalblue;
font-family: Verdana;
}

but you are risking to get some side effects since asp.net uses <span> not
only for labels. I recommend to put up with the pain and keep using
CssClass.

Eliyahu

"Leor Amikam" <am*****@mindspring.com> wrote in message
news:nN********************@comcast.com...
I want to use a css element and apply it to all labels on a page with the
"asp:label" tag.

I defined a CSS class:

.cls1
{
font-weight: bold;
color: royalblue;
font-family: Verdana;
}

and then can assign to the control using the CssClass property:

<asp:label id="Label1" style="Z-INDEX: 101; LEFT: 335px; POSITION: absolute; TOP: 69px" runat="server"
CssClass="cls1" Height="42px" Width="210px">Label</asp:label>

However, this is a pain to have to manually assign to each label control. I want to define one CSS element that maps to "asp:label"
and have it apply to all label controls w/o having to explicitly assign the CssClass. Is there a way to do this?

Thanks!
Leor

Nov 19 '05 #2
OK, thanks.

I guess I could also maybe on page_load time set the style in code.

"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message
news:uG**************@TK2MSFTNGP15.phx.gbl...
Leor,

An asp:label renders as a <span>. You can try

span
{
font-weight: bold;
color: royalblue;
font-family: Verdana;
}

but you are risking to get some side effects since asp.net uses <span> not
only for labels. I recommend to put up with the pain and keep using
CssClass.

Eliyahu

"Leor Amikam" <am*****@mindspring.com> wrote in message
news:nN********************@comcast.com...
I want to use a css element and apply it to all labels on a page with the "asp:label" tag.

I defined a CSS class:

.cls1
{
font-weight: bold;
color: royalblue;
font-family: Verdana;
}

and then can assign to the control using the CssClass property:

<asp:label id="Label1" style="Z-INDEX: 101; LEFT: 335px; POSITION: absolute;
TOP: 69px" runat="server"
CssClass="cls1" Height="42px" Width="210px">Label</asp:label>

However, this is a pain to have to manually assign to each label

control. I
want to define one CSS element that maps to "asp:label"
and have it apply to all label controls w/o having to explicitly assign

the
CssClass. Is there a way to do this?

Thanks!
Leor


Nov 19 '05 #3
Sure, if you prefer that.

Eliyahu

"Leor Amikam" <am*****@mindspring.com> wrote in message
news:-u********************@comcast.com...
OK, thanks.

I guess I could also maybe on page_load time set the style in code.

"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message
news:uG**************@TK2MSFTNGP15.phx.gbl...
Leor,

An asp:label renders as a <span>. You can try

span
{
font-weight: bold;
color: royalblue;
font-family: Verdana;
}

but you are risking to get some side effects since asp.net uses <span> not
only for labels. I recommend to put up with the pain and keep using
CssClass.

Eliyahu

"Leor Amikam" <am*****@mindspring.com> wrote in message
news:nN********************@comcast.com...
I want to use a css element and apply it to all labels on a page with the "asp:label" tag.

I defined a CSS class:

.cls1
{
font-weight: bold;
color: royalblue;
font-family: Verdana;
}

and then can assign to the control using the CssClass property:

<asp:label id="Label1" style="Z-INDEX: 101; LEFT: 335px; POSITION:

absolute;
TOP: 69px" runat="server"
CssClass="cls1" Height="42px" Width="210px">Label</asp:label>

However, this is a pain to have to manually assign to each label

control.
I
want to define one CSS element that maps to "asp:label"
and have it apply to all label controls w/o having to explicitly

assign the
CssClass. Is there a way to do this?

Thanks!
Leor



Nov 19 '05 #4
Leor -

Put a link in your html as below (StylesVerdana in this case is the name of
the style sheet - it will be whatever the name of yours is):

<head>
<title>Title</title>
<meta content="Microsoft Visual Studio .NET 7.1" name=GENERATOR>
<meta content="Visual Basic .NET 7.1" name=CODE_LANGUAGE>
<meta content=JavaScript name=vs_defaultClientScript>
<meta content=http://schemas.microsoft.com/intellisense/ie5
name=vs_targetSchema>

<LINK href="StylesVerdana.css" type=text/css rel=stylesheet >

</head>

I included all of the other code so you could see where it goes.

This will give the proper font to all labels without having to do them
individually. Keep in mind, though, that you will have to individually
insert any font SIZES that are different than the one in your css style sheet.

HTH
--
Sandy
"Leor Amikam" wrote:
I want to use a css element and apply it to all labels on a page with the
"asp:label" tag.

I defined a CSS class:

..cls1
{
font-weight: bold;
color: royalblue;
font-family: Verdana;
}

and then can assign to the control using the CssClass property:

<asp:label id="Label1" style="Z-INDEX: 101; LEFT: 335px; POSITION: absolute;
TOP: 69px" runat="server"
CssClass="cls1" Height="42px" Width="210px">Label</asp:label>

However, this is a pain to have to manually assign to each label control. I
want to define one CSS element that maps to "asp:label"
and have it apply to all label controls w/o having to explicitly assign the
CssClass. Is there a way to do this?

Thanks!
Leor

Nov 19 '05 #5

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

Similar topics

6
by: Buddy Ackerman | last post by:
I created a simple class: Public Class MyTestClass Public Test() As String End Class I tried to assign some values to the array Test() and display them like this:
6
by: Buddy Ackerman | last post by:
I created a simple class: Public Class MyTestClass Public Test() As String End Class I tried to assign some values to the array Test() and display them like this:
1
by: Marc | last post by:
Hi! I'm working with a C# client that calls a php web service. I've created a wrapper to call the service using .NET wsdl tool (adding a web reference). The call to the server works fine, it...
0
by: kamii47 | last post by:
I am creating in memory xmldocument.Previously I were validating my file against a dtd file and then by the help of GetElementByID read my needed node. i.e. XmlDocumentType doctype = null; ...
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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: 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: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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.