R
Rob Roberts
I'm using .NET 2.0 and C# on a web site, and I'm trying to use the
onmouseover and onmouseout events to do a rollover effect on an asp.net
button. I've tried manually adding the events to the asp:button tag. The
events I added look like this:
onmouseover="this.className='btnNormal'"
onmouseout="this.className='btnOver'"
This works fine, with the rollover appearing as it should. But when I build
the project in VS2005, I get a validation warning saying "Validation
(ASP.Net): Attribute 'onmouseover' is not a valid attribute of element
'Button', and another one saying the same thing about onmouseout attribute.
So after searching through newsgroup archives, I found recommendations that
this be done by adding the attributes in the Page_Load event, like this:
MyButton.Attributes.Add("onmouseover", "this.className='btnNormal'");
MyButton.Attributes.Add("onmouseout", "this.className='btnOver'");
But I can't get this to work. It compiles just fine, but the events aren't
included in the HTML sent to the browser, and so of course the rollover
effect doesn't work.
What is the best way to handle rollovers like this?
Thanks in advance,
--Rob Roberts
onmouseover and onmouseout events to do a rollover effect on an asp.net
button. I've tried manually adding the events to the asp:button tag. The
events I added look like this:
onmouseover="this.className='btnNormal'"
onmouseout="this.className='btnOver'"
This works fine, with the rollover appearing as it should. But when I build
the project in VS2005, I get a validation warning saying "Validation
(ASP.Net): Attribute 'onmouseover' is not a valid attribute of element
'Button', and another one saying the same thing about onmouseout attribute.
So after searching through newsgroup archives, I found recommendations that
this be done by adding the attributes in the Page_Load event, like this:
MyButton.Attributes.Add("onmouseover", "this.className='btnNormal'");
MyButton.Attributes.Add("onmouseout", "this.className='btnOver'");
But I can't get this to work. It compiles just fine, but the events aren't
included in the HTML sent to the browser, and so of course the rollover
effect doesn't work.
What is the best way to handle rollovers like this?
Thanks in advance,
--Rob Roberts