I think that you are simply using an invalid attribute. When using
Javascript to change the CSS Class, you use the 'class' attribute.
Therefore, your code should be:
MyButton.Attributes.Add("onmouseover", "this.class='btnNormal'");
MyButton.Attributes.Add("onmouseout", "this.class='btnOver'");
Hopefully this will solve your problem. Good Luck!
--
Nathan Sokalski
njsokalski@hotmail.com http://www.nathansokalski.com/
"Rob Roberts" <robrRemoveThis@AndThisToo.pcisys.net> wrote in message
news:%23q1yh$3IGHA.528@TK2MSFTNGP12.phx.gbl...[color=blue]
> 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
>
>[/color]