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)");
}
}
测试通过。