ASP NET图像的onmouseover不工作 [英] ASP NET image onmouseover not working

查看:181
本文介绍了ASP NET图像的onmouseover不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的第2页的图像。我想要做的是,当我将鼠标移动到第二个图像,第一张图像将变更为其他图像,但事情是行不通的。

I have 2 images in my page. What i want to do is, when i move the mouse over 2nd image, the first image will change to other image, but something is not working.

code:

<asp:Image ID="imgProduct" runat="server" ImageUrl="~/Images/1.png" />
<asp:Image ID="Image1" runat="server" ImageUrl="~/Images/2.png"  onmouseover="imgProduct.src='Images/2.png';"/>

如果我更改的ID的onmouseover =imgProduct.src = 在母版的任何图片ID,该图像被正确地改变,但它不是在默认的页面工作

If i change the ID in onmouseover="imgProduct.src= to any image id in masterpage, that image is changing correctly, but its not working in the default page.

有什么建议?

推荐答案

在Page_Load事件中加入这一行。

On Page_Load event add this line.

Image2.Attributes.Add("onmouseover",imgProduct.ClientID+".src='Images/2.png'");

这篇关于ASP NET图像的onmouseover不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆