ImageButton的图片变换的效果

方法一: javascript

function  mouseOver(id)
      alert(document.getElementById(id).src); 
      document.getElementById(id).src
='images/navigation/3_08.png'; 
  }
 

   
< a href = " index.htm "  onMouseOver = " mouseOver(1) " >  
         
< img src = " images/navigation/3_08.png "  id = " 1 " >  
    
< / a> 

方法二:C#样式的改变
btn.Attributes.Add("class","button");  
  btn.Attributes.Add("onmouseover","this.className='buttonover'");  
  btn.Attributes.Add("onmouseout","this.className='buttonout'");  
  CSS里面对应的部分:  
  .button{width:100;   height:20;BACKGROUND:   url("/AppBaGang/images/button/button_v3.gif")   repeat-y;   border:0   solid   silver;   COLOR:   #ffffff;   FONT-SIZE:   9pt;   FONT-STYLE:   normal;   FONT-VARIANT:   normal;   FONT-WEIGHT:   normal;   LINE-HEIGHT:   normal}  
   
  .buttonover{width:100;   height:20;BACKGROUND:   url("/AppBaGang/images/button/button_v4.gif")   repeat-y;   border:0   solid   silver;   COLOR:   #ffffff;   FONT-SIZE:   9pt;   FONT-STYLE:   normal;   FONT-VARIANT:   normal;   FONT-WEIGHT:   normal;   LINE-HEIGHT:   normal}  
   
  .buttonout{width:100;   height:20;BACKGROUND:   url("/AppBaGang/images/button/button_v3.gif")   repeat-y;   border:0   solid   silver;   COLOR:   #ffffff;   FONT-SIZE:   9pt;   FONT-STYLE:   normal;   FONT-VARIANT:   normal;   FONT-WEIGHT:   normal;   LINE-HEIGHT:   normal}   
   
方法三 最简单的:
btnNew.Attributes.Add("onmouseover",   "this.src='../Imgs/new_over.gif'");  
  btnNew.Attributes.Add("onmouseout",   "this.src='../Imgs/new_out.gif'");

你可能感兴趣的:(imagebutton)