Applying styles from multiple sources

D

DalePres

Is there a way to determine the order or priority of applying styles in a
custom web control? For example, I have a control with default style
settings for many features, and exposed public properties to change those
settings as well. It is easy enough to set the value of the public property
to the default, then use the public property to render my control.

Where it becomes more confusing is when applying style sheets. If a
developer uses my control and applies a style sheet, I have no way of
knowing which style parameters he has applied in the style sheet. Therefore
I don't know which default styles to leave out of my rendering.

So the bottom line is, I think, how to prioritize and apply styles from
default styles, public property styles, and css class styles.

Thanks,

Dale
 
D

Dale

Second try here... Microsoft, Where're those 48 hour responses advertised in
my MSDN subscription?

Is there a way to determine the order or priority of applying styles in a
custom web control? For example, I have a control with default style
settings for many features, and exposed public properties to change those
settings as well. It is easy enough to set the value of the public property
to the default, then use the public property to render my control.

Where it becomes more confusing is when applying style sheets. If a
developer uses my control and applies a style sheet, I have no way of
knowing which style parameters he has applied in the style sheet. Therefore
I don't know which default styles to leave out of my rendering.

So the bottom line is, I think, how to prioritize and apply styles from
default styles, public property styles, and css class styles.

Thanks,

Dale
 
I

Iain

Is there a way to determine the order or priority of applying styles in a
custom web control? For example, I have a control with default style
settings for many features, and exposed public properties to change those
settings as well. It is easy enough to set the value of the public property
to the default, then use the public property to render my control.

(I'm not microsoft, and am asking questions too - so don't expect too
much!).

Dale - I rather think that what happens will happen exactly as if all the
style elements had been included in the resulting html. In fact that may be
exactly how it works. Of course the style parse may well ignore overriden
elements, but it won't know which they are for elements in style sheets
defined outside .net.

So in short I wouldn't worry about it. Any specific style="" in an element
should override higher elements.

Accordingly you should look at the style prioritisation rules.

There's a little bit on this in 'Dynamic HTML' by Danny GOodman and no doubt
an incomprehensible standard at W3C somewhere.


Iain
 
S

Scott G.

I've dropped one of the groups from your xpost.

In general what I do is whenever someone sets the CssClass property of my control I drop all of the internally generated styling; unfortunately, a lot of this is browser dependent -- but in general, the style= attribute is the bottom of the cascade, and thus will override everything before it (modulo any browser bugs). There are some tricky bits here, since some of the CSS qualifiers can set several things at once, for example, one could have :

..tag { font: italic small-caps bold 12px arial; }

And in your HTML:

<foo class="tag" style="font-family: verdana;" >....

In this case we should have overridden the "arial"; but in practice that doesn't always work.

Anyway, because of these kinds of things, I do what I suggested above, which is to not generate a style= if the user sets the CssClass

An alternative might be to never assume any defaults for styling and then if the user of the control sets something, then it's set. Or since you have control of the control you are writing, you could add a property that says/does something like "NoStyleAttribute".

Scott
Second try here... Microsoft, Where're those 48 hour responses advertised in
my MSDN subscription?

Is there a way to determine the order or priority of applying styles in a
custom web control? For example, I have a control with default style
settings for many features, and exposed public properties to change those
settings as well. It is easy enough to set the value of the public property
to the default, then use the public property to render my control.

Where it becomes more confusing is when applying style sheets. If a
developer uses my control and applies a style sheet, I have no way of
knowing which style parameters he has applied in the style sheet. Therefore
I don't know which default styles to leave out of my rendering.

So the bottom line is, I think, how to prioritize and apply styles from
default styles, public property styles, and css class styles.

Thanks,

Dale
 
Q

q

Styles trickle down.

or
think bottom-up.

an embedded style overrides an inline style,
which in turn overrides linked stylesheets.

hope this helps
 
D

DalePres

Thanks all for your advice on this one.

Dale

Styles trickle down.

or
think bottom-up.

an embedded style overrides an inline style,
which in turn overrides linked stylesheets.

hope this helps
 

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,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top