首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

【ASP.NET奇效】为动态创建的表格添加鼠标事件

2011-12-26 
【ASP.NET特效】为动态创建的表格添加鼠标事件1.WEB页代码如下HTML codeasp:table idtable1 runatserver

【ASP.NET特效】为动态创建的表格添加鼠标事件
1.WEB页代码如下

HTML code
<asp:table id=table1 runat=server> <asp:tablerow> <asp:tablecell id=newbtn runat=server> //注意这个id . . 

2.cs中代码如下: 
C# code
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


请问如何为新创建的表格添加如下鼠标代码:
HTML code
onMouseOver="this.style.backgroundColor='#E1E8E8';return true;" onMouseOut="this.style.backgroundColor='#fbfbfb';"




[解决办法]
C# code
newbtn.Attributes.Add("onMouseOver", "this.style.backgroundColor='#E1E8E8';return true;");newbtn.Attributes.Add("onMouseOut","this.style.backgroundColor='#fbfbfb';") 

热点排行