imagebutton help

liunx

Guest
hello, i have an image button in my asp.net page and would like to give it a property so that when the mouse hovers over it the image changes. Just like a rollover image. help please!<asp:ImageButton id="ImageButton1" runat="server" ImageUrl="img_OFF.gif" OnMouseOver=SwapImage(this,"img_ON.gif") OnMouseOut=SwapImage(this,"img_OFF.gif")></asp:ImageButton>


then you need one of these

<script language=javascript>

function SwapImage(image,filename)
{
image.src = <!-- m --><a class="postlink" href="http://www.webdeveloper.com/forum/archive/index.php/filename;">http://www.webdeveloper.com/forum/archi ... /filename;</a><!-- m -->
}

</script>doesnt work bud, it doesnt like the onmouseover or onmouseout tagsum, actualy it does work.... for me. I tested it.

What are you developing it with? I wrote that using VS.NET and vs opened up IE for me.

The tag's arn't in the asp.net imagebutton. I guess when they process it, if they dont match they just get sent directly to the <input type="image" attributes.hmm, could you please send me the test page you did so i can have a look, i cant figure it out! :)<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="QuickTest.WebForm1" %>
<HTML>
<HEAD>
<TITLE>WebForm1</TITLE>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
<script language=javascript>

function SwapImage(image,filename)
{
image.src = <!-- m --><a class="postlink" href="http://www.webdeveloper.com/forum/archive/index.php/filename;">http://www.webdeveloper.com/forum/archi ... /filename;</a><!-- m -->
}

</script>
</HEAD>
<body>
<form runat="server">
<asp:ImageButton id="ImageButton1" runat="server" ImageUrl="R6_1.jpg" OnMouseOver=SwapImage(this,"R6_2.jpg") OnMouseOut=SwapImage(this,"R6_1.jpg")></asp:ImageButton>
</body>
</HTML>


and it produces



<HTML>
<HEAD>
<TITLE>WebForm1</TITLE>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
<script language=javascript>

function SwapImage(image,filename)
{
image.src = <!-- m --><a class="postlink" href="http://www.webdeveloper.com/forum/archive/index.php/filename;">http://www.webdeveloper.com/forum/archi ... /filename;</a><!-- m -->
}

</script>
</HEAD>
<body>
<form name="_ctl0" method="post" action="WebForm1.aspx" id="_ctl0">
<input type="hidden" name="__VIEWSTATE" value="dDwyMDUxMjYqr34234f4234234fdghe6KSDRzIIkca92EG3k5jNyOw93" />

<input type="image" name="ImageButton1" id="ImageButton1" OnMouseOver="SwapImage(this,"R6_2.jpg")" OnMouseOut="SwapImage(this,"R6_1.jpg")" src=http://www.webdeveloper.com/forum/archive/index.php/"R6_1.jpg" alt="" border="0" />
</form>
</body>
</HTML>
 
Back
Top