Hello Everyone, i am trying to do a mouseOver event in my Default.aspx page where the image changes on a mouseOver. The code I have below trying to add an attribute which changes the imageButton picture does not work, when the page is requested it gets rendered fine but when i enter the imageButton control with my cursor the browser comes up "Web Page Error". When i dubug the debugger comes up with this "breaking on JScript run time error - Object expected".
Any help would be greatly appreciated.
Mark
Default.aspx
Code:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ImageButton ID="ImageButton1" runat="server" Height="139px"
ImageUrl="~/Images/Picture2.jpg" Width="158px" />
</div>
</form>
</body>
</html>
Page Behind
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
ImageButton1.Attributes["onMouseOver"] = "javascript:swapImageIn('~/Images/Picture1.jpg');return true;";
ImageButton1.Attributes["onMouseOut"] = "javascript:swapImageOut();return true;";
}
}