Asp.net 鼠标单击treeview childs时保持背景色
当鼠标单击ASP.NET TreeView中的任意一个子项时,如何保持背景色?对树视图使用treenodedatabound事件,并为每个项添加onclick事件,以调用javascript函数来执行任何您想要的操作Asp.net 鼠标单击treeview childs时保持背景色,asp.net,Asp.net,当鼠标单击ASP.NET TreeView中的任意一个子项时,如何保持背景色?对树视图使用treenodedatabound事件,并为每个项添加onclick事件,以调用javascript函数来执行任何您想要的操作 protected void TreeView1_TreeNodeDataBound(object sender, TreeNodeEventArgs e) { e.Node.Text = "<span onclick='javas
protected void TreeView1_TreeNodeDataBound(object sender, TreeNodeEventArgs e)
{
e.Node.Text = "<span onclick='javascript:MyFunction(this);'>Text</span>";
}
你能提供“javascript:MyFunction(this)”吗;函数?函数MyFunction(sender){//使用jquery,您有html元素(td),您可以根据senario从该元素中获取任何值//例如,您有一个名为x的属性,该属性包含您想要的值alert($(sender).attr(“x”);//或更改背景色$(sender).css(“背景色”,“蓝色”);}我不确定sender.style.backgroundColor='red'的语法;你好,Titan先生,我被禁止使用jquery。你能用javascript提供吗
Dim deletenode As New TreeNode("<span onclick=""javascript:confirm('Are you sure you want to delete this ?');"">Delete</span>", "0" & dr("ProjectID"))
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");
}