Can onmouseover change row borders?

  • Thread starter Thread starter Arch
  • Start date Start date
A

Arch

I have a datagrid with alternating bg colors, and I added an onmouseover
event to shade them yet another color. Here's the way Google taught me
to do it:

If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
ListItemType.AlternatingItem Then
e.Item.Attributes.Add("onmouseover", "this.style.backgroundColor='#DFCBFF'")
End If

If e.Item.ItemType = ListItemType.Item Then
e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='White'")
Elseif e.Item.ItemType = ListItemType.AlternatingItem Then
e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='#CFD1FB'")
End If

But the effect is too busy, and I'd like to experiment with other
effects - specifically, I'd like to leave the bg color the same and show
the top and bottom borders of the rolled-over row. Is there a way to use
code similar to mine to change other attributes of a row when the mouse
goes over it? Or any way?

Thanks for any help.
 
Arch said:
I have a datagrid with alternating bg colors, and I added an onmouseover
event to shade them yet another color. Here's the way Google taught me to
do it:

If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
ListItemType.AlternatingItem Then
e.Item.Attributes.Add("onmouseover",
"this.style.backgroundColor='#DFCBFF'")
End If

If e.Item.ItemType = ListItemType.Item Then
e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='White'")
Elseif e.Item.ItemType = ListItemType.AlternatingItem Then
e.Item.Attributes.Add("onmouseout",
"this.style.backgroundColor='#CFD1FB'")
End If

But the effect is too busy, and I'd like to experiment with other
effects - specifically, I'd like to leave the bg color the same and show
the top and bottom borders of the rolled-over row. Is there a way to use
code similar to mine to change other attributes of a row when the mouse
goes over it? Or any way?

Thanks for any help.

What that code ultimately does is use JavaScript to modify the CSS property
of "backgroundColor". You could substitute any other valid style property
and set it accordingly. For example:

e.Item.Attributes.Add("onmouseover", "this.style.color='#ff0000'")

would cause the text color to change to red.

It all is based on the JavaScript/DHTML "style" object:

http://www.w3schools.com/jsref/dom_obj_style.asp

-Scott
 
Scott said:
What that code ultimately does is use JavaScript to modify the CSS property
of "backgroundColor". You could substitute any other valid style property
and set it accordingly. For example:

e.Item.Attributes.Add("onmouseover", "this.style.color='#ff0000'")

would cause the text color to change to red.

It all is based on the JavaScript/DHTML "style" object:

http://www.w3schools.com/jsref/dom_obj_style.asp

-Scott
Scott, this is just perfect. I swear I tried this, but I must not have
got my syntax right. That link you gave me is exactly what I needed to
play with my code. Thanks so much.

Grateful Noob :|
 
Arch said:
Scott, this is just perfect. I swear I tried this, but I must not have got
my syntax right. That link you gave me is exactly what I needed to play
with my code. Thanks so much.

Grateful Noob :|

No problem. Good luck.

-Scott
 
Back
Top