ImageButton 鼠标经过时如何换图片。网上有方法在load里面加  
       ImageButton1.Attributes.Add("onmouseover", "this.src=images/a1.JPG ");
        ImageButton1.Attributes.Add("onmouseout ", "this.src=images/a2.JPG ");
我试了很多个都不管用啊!那位高手帮下忙!

解决方案 »

  1.   

    直接onmouseover="this.src=images/a1.JPG "不行么
      

  2.   

    this.ImageButton1.Attributes["onmouseover"]="this.src='../images/1.gif';";
      

  3.   

    可以在button的onmouseover事件里写
    服务器端相对简单些
    如果是在客户端的话,要调用js了
      

  4.   

    ImageButton本来就没有 onmouseover 这个属性!根本不执行!
      

  5.   

    Page_Load里边加下边的代码。。我的倒是没问题~this.ImageButton1.Attributes["onmouseover"]="this.src='../images/C2.gif';";
    this.ImageButton1.Attributes["onmouseout"]="this.src='../images/C1.gif';";
      

  6.   

    发现我好值得BS.....ImageButton1.Attributes.Add("onmouseover", "this.src='images/a1.JPG'");
    ImageButton1.Attributes.Add("onmouseout ", "this.src='images/a2.JPG'"); 
      

  7.   

    ImageButton本来就没有 onmouseover 这个属性!根本不执行!
    -------------------------
    这个是html元素的常见事件,作为服务器端控件不一定有这个属性,很正常的!
    ImageButton最终会被解析成html元素的!猜测你的路径错误了
      

  8.   

    问题找到,是我的原因,我做了input的CSS样式!这个就不执行!谢谢高手们!散分!
      

  9.   

            ImageButton1.Attributes.Add("onmouseover", "this.src='images/a1.jpg'");
            ImageButton1.Attributes.Add("onmouseout", "this.src='images/a2.jpg'"); 
    来晚了,单引号问题!!
      

  10.   

    上面的也可以
    <asp:ImageButton ID="ImageButton1" onmouseover="this.src='1.gif'" onmouseout="this.src='2.gif'" runat="server" />
    这也是一种 方法多了
      

  11.   

    ImageButton1   没有onmouseover和onmouseout属性,还是用CSS解决吧。