Why isn't my style being used ?

  • Thread starter Thread starter JezB
  • Start date Start date
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 ?
 
Does it work with something else ? H2 could perhaps conflict with html H2
tag ???

Patrice
 
There is no html H2 tag ... I've only just started learning about
stylesheets so I may be doing something silly.
 
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
 
Ah I see ... so controls have to be based on a "custom" class rather than
one of the predefined HTML ones ?
 
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
 
Back
Top