在C#代码里,
document.getElementById('"+uu.ClientID +"').style.background='#DCDCDC';
以上是背景颜色,要是改成背景图片,如何写?

解决方案 »

  1.   

    这不是C#,这是JavaScriptdocument.getElementById('"+uu.ClientID +"').style.background-image="url(../images/css_tutorials/background.jpg)";
      

  2.   

    我是在.cs里写的
    h2.Attributes.Add("onmouseover",document.getElementById('"+uu.ClientID +"').style.background-image='url(../img/1.gif)';");
    =================
    还是不对啊?
      

  3.   

    用JS来写
    参考下面的网站:
    http://www.cnblogs.com/allanbolt/archive/2009/12/28/1634144.html
    在JS中设置一下把你鼠标经过的换一个样式就可以了
      

  4.   

    应该是这样:
    js:
    document.getElementById("youId").style.backgroundImage = "url('../img/1.gif')"; 
      

  5.   

    _$("ImgId").backgroundImage="url('../img/1.gif')"; 
      

  6.   

    以上代码都测试了都不行啊
    我是在index.aspx.cs里写的
    h2.Attributes.Add("onmouseover",document.getElementById('"+uu.ClientID +"').style.background-image='url(http://www.baidu.com/img/logo-yy.gif)';");
      

  7.   

    怎么可能??
    你调用js!!
    h2.Attributes.Add("onmouseover","test()");js
    function test()
    {
    document.getElementById("youId").style.backgroundImage = "url('../img/1.gif')"; 
    }
      

  8.   

    JS是写在页面中的....<head><script type="text/javascript">
    document.getElementById("控件ID名字").style.backgroundImage = "url('背景图片地址')";
    </script></head>
      

  9.   

    .style.background='url(http://www.baidu.com/img/logo-yy.gif)'
    ==============
    这个是正确代码。在公司这台电脑测试不行,回家测试就可以了,怪事情。
    谢谢大家了