foo.Attribute["onmouseover"] = "javascript:foo();";

解决方案 »

  1.   

    不可能不行的啊,
    <asp:button id="button1" runat=server onmouseover="overCss()" onmouseout="outCss()">
    </asp:button><script>
    function overCss(){
       document.all("button1").className="样式1"
    }function outCss(){
       document.all("button1").className="样式2"}function outColor
    </script>这样就可以了,我试过了,无论是否是服务器控件
      

  2.   

    更正:
    function outColor 一行不需要
      

  3.   

    楼上说的我也试过了,一般情况下都是对的。可是服务器端的控件如果有了style再指定其className时好像就无效了。在更改className前,后台已经为button指定了颜色,所以在客户端产生时已经具有了style,现在是这种情况下怎么办。
      

  4.   

    btn.Attributes.Add("onmouseover", "this.style.backgroundColor='#ffccaa'");
    btn.Attributes.Add("onmouseout", "this.style.backgroundColor='#efefcf'");
      

  5.   

    可以用button1.style.backgroundColor = "yellow";