开发者

Maintaining backcolor when mouse click on treeview childs

开发者 https://www.devze.com 2022-12-20 23:52 出处:网络
How to maintain background color when mouse click any one of the children in ASP.NET TreeVie开发者_如何学编程w?Use the treenodedatabound event for the tree view and add for each item onclick event to

How to maintain background color when mouse click any one of the children in ASP.NET TreeVie开发者_如何学编程w?


Use the treenodedatabound event for the tree view and add for each item onclick event to call a javascript function to do whatever you want

   protected void TreeView1_TreeNodeDataBound(object sender, TreeNodeEventArgs e)
        {
           e.Node.Text = "<span onclick='javascript:MyFunction(this);'>Text</span>";
        }

or you can add the items in this way

Dim deletenode As New TreeNode("<span onclick=""javascript:confirm('Are you sure you want to delete this ?');"">Delete</span>", "0" & dr("ProjectID"))

Js function sample

MyFunction(sender) { 
//using jquery you have the html element (td ) you can get any value from that element based on your senario 
//for example you have attribute called x holding the value you want 
alert( $(sender).attr("x")); 

//or to change the background color 
$(sender).css("background-color" , "blue"); 

} 
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号