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 3 7413
Rob Roberts wrote: 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.
This is the job of JavaScript and/or CSS. Posting back to a server for
these events would put excessive load on your server. Not to mention
that it would be incredibly slow.
HTH,
--
Sean
"Fao, Sean" <en**********@yahoo.comI-WANT-NO-SPAM> wrote in message
news:uf*************@TK2MSFTNGP12.phx.gbl... Rob Roberts wrote: 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.
This is the job of JavaScript and/or CSS. Posting back to a server for these events would put excessive load on your server. Not to mention that it would be incredibly slow.
Well, yes, but that's what I'm trying to do. That's why I first tried
adding these event handlers to the button declaration in the aspx file:
onmouseover="this.className='btnNormal'"
onmouseout="this.className='btnOver'"
And while that works just fine in giving the desired rollover effect
(without a postback to the server), VS2005 complains about it, saying that
"Attribute 'onmouseover' is not a valid attribute of element 'Button'".
--Rob Roberts
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 nj********@hotmail.com http://www.nathansokalski.com/
"Rob Roberts" <ro************@AndThisToo.pcisys.net> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl... 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
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: christian9997 |
last post by:
Hi
I was trying to create a page where a SubMenu would appear when the
user moved the mouse over an item of a Menu (= Table Cell <TD>).
Unfortunately there seems to be a problem; the onMouseOver...
|
by: Epetruk |
last post by:
Hi all,
I want a page where the contents of a table cell are replaced with an image
when the mouse moves over the cell, and the text is restored when the mouse
moves out. Here's the html for the...
|
by: Bendik Engebretsen |
last post by:
Hi,
ASP.NET newbie has just started expermenting with VS.NET 2005 Beta, ASP.NET
2.0 and the 'Personal WEB site' starter kit. I am now trying to create a
rollover effect on the buttons. I have...
|
by: MrCode2k |
last post by:
Hello,
Trying to do: I just want a table that I can scroll and that has fixed
headers.
Problem: I got it to work but when I added the onmouseover event it
didn't work anymore....
|
by: mike.thirlwell |
last post by:
Hi there,
I've created the following demo to illustrate a problem I've been
having with Safari (2.0.3 in my case) firing onmouseout events when the
onmouseover event should be being triggered....
|
by: jceddy |
last post by:
Hi...I hope I am posting this in an appropriate place...if not, could
some direct me to someplace better?
Anyway, the problem I have is that I have a page with a table with two
rows. The top...
|
by: oopaevah |
last post by:
I have written some dom code to create a list of divs, each with it's
own id. I want to set the onmouseover and onmouseout events to
highlight the div when the mouse is over it. However I cannot...
|
by: Daz |
last post by:
Hi everyone.
I think my problem is a simple one, but I am completely baffled as to
how to pull it off.
I have a piece of code like so...
document.write(
"<img id=\"slideshow_toggle\"...
|
by: equazcion |
last post by:
Hi,
I have an image reference (IMG) in my page that changes depending on the value of a database field. Clicking the image triggers an Ajax call to change the database field (toggles the field...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |