0

So I'm aware that to add a "regular" style to an object in asp you use:

object.Style.Add("background-color", "red");

Is there any way to add a style but with the :hover selector? Can't find any useful info skimming the web.

Thanks a lot!

Gaspa79
  • 5,488
  • 4
  • 40
  • 63
  • object.Attributes.Add("onmouseover", "background-color:red'"); Not sure if this is going to work. if not you can assign JS function and write it in aspx page. HTH – rach Aug 27 '14 at 16:45
  • Yes I'm aware that you can add attributes and assign js functions. I just want to know if there's an easy hover way (which I don't think there is) – Gaspa79 Aug 27 '14 at 16:46
  • Look at: http://stackoverflow.com/questions/13109967/underlining-in-javascript – rkawano Aug 27 '14 at 16:47

1 Answers1

1

You can't do this with the :hover selector. The :hover pseudo selector can't be applied/used in inline-styles. object.Style applies inline styles. You should be using stylesheets anyway and not inline styles.

Dave Zych
  • 21,581
  • 7
  • 51
  • 66