当前位置: 代码迷 >> ASP.NET >> ImageButton 如何设置鼠标指向改变图片
  详细解决方案

ImageButton 如何设置鼠标指向改变图片

热度:6152   发布时间:2013-02-25 00:00:00.0
ImageButton 怎么设置鼠标指向改变图片
ImageButton 怎么设置鼠标指向改变图片,就像a标签的hover

------解决方案--------------------------------------------------------
OnMouseOut="this.src='img/1.jpg';" OnMouseOver="this.src='img/2.jpg';"
------解决方案--------------------------------------------------------
web页面:
<script language="javascript" type="text/javascript">
function mouseover(obj){
obj.src="../index_join.jpg";
}
function mouseout(obj){
obj.src="";
}
</script>

</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ImageButton ID="ImageButton1" runat="server" /></div>

</form>
</body>
</html>


.cs:

protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack){
this.ImageButton1.Attributes.Add("OnMouseOver", "mouseover(this)");
this.ImageButton1.Attributes.Add("OnMouseOut", "mouseout(this)");
}
}

测试通过。