CSS Classes can cause problems

T

tshad

I just found an interesting anomaly that I had not seen before.

It seems to affect both Datalist and Datagrids. If you set the background
color of the DataGrids using CSSClass (which is valid) instead of using
backcolor, you cannot programmatically set the color of the datalistitem or
datagriditem.

I was doing this to indicate which row the user wanted to move. I would set
the color as green. But I found that every other color would not show the
green color. After some checking I found that I had set the alternating
color as linen like so:

<alternatingitemstyle CssClass=alternateRow
</alternatingitemstyle>

if I set it as:

<alternatingitemstyle backcolor="linen"
</alternatingitemstyle>

I have no problem.

I am not sure why it works ok with backcolor, but I assume that when I
programmatically set the color like so:

Dim oDLI as DataListItem = s.parent.parent
oDLI.BackColor = System.Drawing.Color.Green

when the page is returned the CSS Class is applied over the color I had set.

Interesting, but not fun.

Tom
 
T

tshad

tshad said:
I just found an interesting anomaly that I had not seen before.

It seems to affect both Datalist and Datagrids. If you set the background
color of the DataGrids using CSSClass (which is valid) instead of using
backcolor, you cannot programmatically set the color of the datalistitem
or datagriditem.

I was doing this to indicate which row the user wanted to move. I would
set the color as green. But I found that every other color would not show
the green color. After some checking I found that I had set the
alternating color as linen like so:

<alternatingitemstyle CssClass=alternateRow

if I set it as:

<alternatingitemstyle backcolor="linen"

I have no problem.

I am not sure why it works ok with backcolor, but I assume that when I
programmatically set the color like so:

Dim oDLI as DataListItem = s.parent.parent
oDLI.BackColor = System.Drawing.Color.Green

when the page is returned the CSS Class is applied over the color I had
set.

Interesting, but not fun.

I just found that it only has a problem in Mozilla and not in IE.

In mozilla, the code from viewsource shows:

<tr class="alternateRow" bgcolor="Green">

In IE it shows as:

<td class="alternateRow" style="background-color:Green;">

Bot have the class set, but for some reason Mozilla chooses the class, and
IE chooses the style. It is also interesting that Mozilla converts my
"oDGI.BackColor = System.Drawing.Color.Green" to bgcolor and IE converts it
to a style.

Tom
 

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,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top