Can onmouseover change row borders?

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.
 
S

Scott M.

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
 
A

Arch

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 :|
 
S

Scott M.

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
 

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

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top