日期:2014-05-18  浏览次数:20421 次

ImageButton鼠标放到button时,改变图片
function   MM_swapImage()   {   //v3.0
    var   i,j=0,x,a=MM_swapImage.arguments;   document.MM_sr=new   Array;   for(i=0;i <(a.length-2);i+=3)
      if   ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x;   if(!x.oSrc)   x.oSrc=x.src;   x.src=a[i+2];}


  <a   href= "# "   onmouseout= "MM_swapImgRestore() "   onmouseover= "MM_swapImage( 'Image23 ', ' ', '~/images/subway_over.gif ',1) ">
                       
                                <asp:ImageButton   ID= "ImageButton2 "   runat= "server "     ImageUrl= "~/images/subway.gif "   OnClick= "ImageButton2_Click "/> </a>
                        </td>

怎么不行啊,客户端de可以


------解决方案--------------------
//aspx
<asp:ImageButton ID= "ImageButton2 " runat= "server " ImageUrl= "~/images/1.gif " />

//aspx.cs

private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{
ImageButton2.Attributes.Add( "onmouseover ", "this.src= 'images/2.gif ' ");
ImageButton2.Attributes.Add( "onmouseout ", "this.src= 'images/1.gif ' ");
}
}