Why isn't my style being used ?

J

JezB

Im my Page_Load method I create a label dynamically and add it to my Page:

Label l = new Label();
l.Text = "Example";
l.CssClass = "H2";
this.Controls.Add(l);

My page is linked to an external stylesheet, but when the control is
rendered it is not using the H2 style - what am I missing ?
 
P

Patrice

Does it work with something else ? H2 could perhaps conflict with html H2
tag ???

Patrice
 
J

JezB

There is no html H2 tag ... I've only just started learning about
stylesheets so I may be doing something silly.
 
P

Patrice

Show us the style sheet. You should have a dot before h2 so that it is taken
as a class name. If you used only "h2" in your style sheet, it is the style
to apply to the html h2 tag (which is used for headers).


Patrice
 
J

JezB

Ah I see ... so controls have to be based on a "custom" class rather than
one of the predefined HTML ones ?
 
J

JezB

thanks .... still learning

Patrice said:
Show us the style sheet. You should have a dot before h2 so that it is taken
as a class name. If you used only "h2" in your style sheet, it is the style
to apply to the html h2 tag (which is used for headers).


Patrice
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top