1.WEB页代码如下
<asp:table id=table1 runat=server> 
<asp:tablerow> 
<asp:tablecell id=newbtn runat=server> //注意这个id 


2.cs中代码如下: 
System.Web.UI.WebControls.Button btnlastYV = new System.Web.UI.WebControls.Button(); 
btnlastYV.Text = "OK"; 
btnlastYV.ID = "btnlastYV"; 
btnlastYV.Click +=new EventHandler(btnlastYV_Click); 
newbtn.Controls.Add(btnlastYV); //添加button到cell请问如何为新创建的表格添加如下鼠标代码:
onMouseOver="this.style.backgroundColor='#E1E8E8';return true;" onMouseOut="this.style.backgroundColor='#fbfbfb';"

解决方案 »

  1.   


    newbtn.Attributes.Add("onMouseOver", "this.style.backgroundColor='#E1E8E8';return true;");
    newbtn.Attributes.Add("onMouseOut","this.style.backgroundColor='#fbfbfb';")
      

  2.   

    添加了鼠标事件后发现没有实现我想像中的效果
    这个代码最后效果,是把所有(newbtn.Controls.Add(btnlastYV); //添加button到cell)
    都添加到一个CELL里面
    怎么设置成每次添加都是一个单独的CELL
    这样才有鼠标移动过去变色的效果 
    因为我要添加不止一条信息
    谢谢!
      

  3.   

    我用一个LABEL实现了,  结贴了