2个imagebutton(imagebutton1,imagebutton2)
首先给2个imagebutton都赋好图片了,我现在想,点击imagebutton1的时候,就把它本身的图片从1.gif换到2.gif
点击imagebutton2时,imagebutton1的图片变为1.gif,同时imagebutton2本身的图片从3.gif换到4.gif
如此循环(多个imagebutton时).并且imagebutton还要实现跳转或提交的事件。
图片的更换用js怎么实现?

解决方案 »

  1.   

    document.getElementById("image").src="";
      

  2.   

    click事件中
    imagebutton1.ImageUrl="~/路径/文件名"
      

  3.   

    图片的更换用js怎么实现?js实现的一提交不是丢失了吗
      

  4.   

    imagebutton我是打算放在母版页中的,只会刷新子页吧
    我看很多网站都能这样实现,点击按钮,按钮就凹下去了,下面的页面就刷新了
      

  5.   

    母版页是刷新整个页面的。
    ajax才是局部刷新的。如果刷新页面,做法是不同的。下面是一种做法<%@ Page Language="C#" Debug="true" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
      <title></title>
      <script>
        function SetImage(o) {
          o.src = o.getAttribute("OldImage");
          SetCookie("id", o.id)
        }    function SetCookie(cookieName, cookieValue) {
          var today = new Date();
          var expire = new Date();
          expire.setTime(today.getTime() + 1000 * 60 * 60 * 24 * 1);
          document.cookie = cookieName + "=" + escape(cookieValue) + ";expires=" + expire.toGMTString();
        }    function GetCookie(cookieName) {
          var theCookie = "" + document.cookie;
          var ind = theCookie.indexOf(cookieName);
          if (ind == -1 || cookieName == "")
            return "";
          var ind1 = theCookie.indexOf(';', ind);
          if (ind1 == -1)
            ind1 = theCookie.length;
          return unescape(theCookie.substring(ind + cookieName.length + 1, ind1));
        }
        window.onload = function () {
          if (GetCookie("id") != "") document.getElementById(GetCookie("id")).src = document.getElementById(GetCookie("id")).getAttribute("OldImage");
        }
      </script>
    </head>
    <body>
      <form id="form1" runat="server">
      <asp:ImageButton ID="ImageButton1" runat="server" Height="53px" Width="189px" OnClientClick="SetImage(this)"
        OldImage="2.gif" ImageUrl="1.gif" />
      <asp:ImageButton ID="ImageButton2" runat="server" OldImage="http://dotnet.aspx.cc/Images/qrcode.png"
        ImageUrl="http://dotnet.aspx.cc/Images/logoSite.gif" Height="53px" Width="189px"
        OnClientClick="SetImage(this);return false" />
      </form>
    </body>
    </html>
      

  6.   

    那是js+div+css实现的。你百度搜索 js滑动门 就可以看到很多列子应该
      

  7.   

    当然,还有很多其他的做法,还可以通过url传递参数,很多网站为了简单,都是一个页面写定死的了
      

  8.   

    那怎么实现你说的这个局部刷新
    同时imagebutton图片更换(客服端)