Groups | Blog | Home
all groups > asp.net webcontrols > december 2005 >

asp.net webcontrols : Is there a way to set onmouseover for a LinkButton in ASP.NET 2.0 ?



Roberto Kohler
12/27/2005 4:39:23 PM
Is there a way within ASP.NET 2.0 to set the onmouseover property of a
LinkButton so that when the user hovers over the LinkButton, the windows
status bar displays some text instead of the javascript command ?

I'd like to do something like:
<asp:LinkButton ID="LinkEdit" Runat="server" CommandName="Edit">
onMouseOver="LinkButton_onMouseOver ('Click here to Edit the Record')"
onMouseOut="LinkButton_onMouseOut"
</asp:LinkButton>

function LinkButton_onMouseOver (strStatus)
{ window.status=strStatus; return true; }

function LinkButton_onMouseOut ()
{ window.status=""; return true; }

Nathan Sokalski
1/4/2006 4:33:38 PM
I do not believe there is a built-in way to do this in ASP.NET, but a common
workaround is to use the Attributes collection. Use onMouseOver or
onMouseOut as the Key, and use the script you want to be run as the Value.
For example:

LinkEdit.Attributes.Add("onMouseOut","window.status=''; return true;")

If you would prefer to use functions define the functions inside script tags
in the .aspx file and do the following:

LinkEdit.Attributes.Add("onMouseOut","LinkButton_onMouseOut();")

Good Luck!
--
Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansokalski.com/

[quoted text, click to view]

AddThis Social Bookmark Button