Home All Groups Group Topic Archive Search About

Is there a way to set onmouseover for a LinkButton in ASP.NET 2.0 ?

Author
27 Dec 2005 9:39 PM
Roberto Kohler
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; }

Author
4 Jan 2006 9:33 PM
Nathan Sokalski
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
njsokal***@hotmail.com
http://www.nathansokalski.com/

Show quoteHide quote
"Roberto Kohler" <rkoh***@intranetslab.com> wrote in message
news:emnph4yCGHA.4068@TK2MSFTNGP14.phx.gbl...
> 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; }
>