Wednesday, March 28, 2012

Why isnt my style being used ?

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

"JezB" <jezb@.somewhere.com> a crit dans le message de
news:%23BnN%234jQEHA.964@.TK2MSFTNGP10.phx.gbl...
> 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 ?
There is no html H2 tag ... I've only just started learning about
stylesheets so I may be doing something silly.

"Patrice" <nobody@.nowhere.com> wrote in message
news:u27QeIkQEHA.2216@.TK2MSFTNGP12.phx.gbl...
> Does it work with something else ? H2 could perhaps conflict with html H2
> tag ?
> Patrice
> "JezB" <jezb@.somewhere.com> a crit dans le message de
> news:%23BnN%234jQEHA.964@.TK2MSFTNGP10.phx.gbl...
> > 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 ?
Hi

In CSS
..myClass
{
font-family:verdana,arial
}

l..CssClass = "myClass";

More info
http://msdn.microsoft.com/library/d...rence_entry.asp

--
Best Regards
Vidar Petursson
==============================
Microsoft Scripting MVP
http://www.icysoft.com/
http://www.microsoft.com/technet/scriptcenter

No matter where you go there you are
==============================
"JezB" <jezb@.somewhere.com> wrote in message
news:OqmdSWkQEHA.1276@.TK2MSFTNGP11.phx.gbl...
> There is no html H2 tag ... I've only just started learning about
> stylesheets so I may be doing something silly.
> "Patrice" <nobody@.nowhere.com> wrote in message
> news:u27QeIkQEHA.2216@.TK2MSFTNGP12.phx.gbl...
>> Does it work with something else ? H2 could perhaps conflict with html H2
>> tag ?
>>
>> Patrice
>>
>> "JezB" <jezb@.somewhere.com> a crit dans le message de
>> news:%23BnN%234jQEHA.964@.TK2MSFTNGP10.phx.gbl...
>> > 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 ?
>>>>
>>
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

"JezB" <jezb@.somewhere.com> a crit dans le message de
news:OqmdSWkQEHA.1276@.TK2MSFTNGP11.phx.gbl...
> There is no html H2 tag ... I've only just started learning about
> stylesheets so I may be doing something silly.
> "Patrice" <nobody@.nowhere.com> wrote in message
> news:u27QeIkQEHA.2216@.TK2MSFTNGP12.phx.gbl...
> > Does it work with something else ? H2 could perhaps conflict with html
H2
> > tag ?
> > Patrice
> > "JezB" <jezb@.somewhere.com> a crit dans le message de
> > news:%23BnN%234jQEHA.964@.TK2MSFTNGP10.phx.gbl...
> > > 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 ?
> >
Ah I see ... so controls have to be based on a "custom" class rather than
one of the predefined HTML ones ?

"Vidar Petursson" <thekingYoUKnOwWhatToDoHEREeh@.icysoft.com> wrote in
message news:eqBfzbkQEHA.252@.TK2MSFTNGP10.phx.gbl...
> Hi
> In CSS
> .myClass
> {
> font-family:verdana,arial
> }
> l..CssClass = "myClass";
> More info
http://msdn.microsoft.com/library/d...rence_entry.asp
> --
> Best Regards
> Vidar Petursson
> ==============================
> Microsoft Scripting MVP
> http://www.icysoft.com/
> http://www.microsoft.com/technet/scriptcenter
> No matter where you go there you are
> ==============================
> "JezB" <jezb@.somewhere.com> wrote in message
> news:OqmdSWkQEHA.1276@.TK2MSFTNGP11.phx.gbl...
> > There is no html H2 tag ... I've only just started learning about
> > stylesheets so I may be doing something silly.
> > "Patrice" <nobody@.nowhere.com> wrote in message
> > news:u27QeIkQEHA.2216@.TK2MSFTNGP12.phx.gbl...
> >> Does it work with something else ? H2 could perhaps conflict with html
H2
> >> tag ?
> >>
> >> Patrice
> >>
> >> "JezB" <jezb@.somewhere.com> a crit dans le message de
> >> news:%23BnN%234jQEHA.964@.TK2MSFTNGP10.phx.gbl...
> >> > 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 ?
> >> >> >>
> >>
thanks ... still learning

"Patrice" <nobody@.nowhere.com> wrote in message
news:eJeD5mkQEHA.624@.TK2MSFTNGP11.phx.gbl...
> 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
> "JezB" <jezb@.somewhere.com> a crit dans le message de
> news:OqmdSWkQEHA.1276@.TK2MSFTNGP11.phx.gbl...
> > There is no html H2 tag ... I've only just started learning about
> > stylesheets so I may be doing something silly.
> > "Patrice" <nobody@.nowhere.com> wrote in message
> > news:u27QeIkQEHA.2216@.TK2MSFTNGP12.phx.gbl...
> > > Does it work with something else ? H2 could perhaps conflict with html
> H2
> > > tag ?
> > > > Patrice
> > > > "JezB" <jezb@.somewhere.com> a crit dans le message de
> > > news:%23BnN%234jQEHA.964@.TK2MSFTNGP10.phx.gbl...
> > > > 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 ?
> > > > > >

0 comments:

Post a Comment