Could'nt Find MouseHover Event

G

Guest

I'm a user of Visual Studio Web Developer 2005 Express Edition & I use C# as
the language in it. So, the problem i'm facing is that I want to add a
MouseHover event to an image but i could'nt find it in the Events' list in
Properties window as in Microsoft Visual C# 2005 Express Edition.Can you tell
me where it lies or isthere any other way to do it in Web Developer. I'll be
thankful if you solve my problem.

Saurabh
 
K

Ken Cox [Microsoft MVP]

Hi Saurabh,

In the Web page, the mouseover event is a client event, so you won't find it
in C# server-side events. However, you can add the JavaScript code in
ASP.NET.

See the code sample below that demonstrates the technique.

Let us know if this helps?

Ken
Microsoft MVP [ASP.NET]

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

protected void Page_Load
(object sender, EventArgs e)
{
ImageButton1.Attributes.Add("onmouseover",
"this.src='http://www.gc.ca/images/francaisbt.gif'");
ImageButton1.Attributes.Add("onmouseout",
"this.src='http://www.gc.ca/images/englishbt.gif'");
}
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>MouseOver MouseOut Image</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:imagebutton id="ImageButton1" runat="server"
imageurl="http://www.gc.ca/images/englishbt.gif" /></div>
</form>
</body>
</html>
 
G

Guest

Hi Ken,
Thanks, it did work & this much programing I can do to modify it
according to my requirements. But i still want to know if it is possible
using C# in Web Developer.
 
G

Guest

Hi Ken,
I have another question. How can I change the picture of
onmouseover & onmouseout event. I mean can I import the picture file for my
website. It properly shows the picture which is on the internet but not the
one which is on my pc when i debug the web application.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top