Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 鼠标单击treeview childs时保持背景色_Asp.net - Fatal编程技术网

Asp.net 鼠标单击treeview childs时保持背景色

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

当鼠标单击ASP.NET TreeView中的任意一个子项时,如何保持背景色?

对树视图使用treenodedatabound事件,并为每个项添加onclick事件,以调用javascript函数来执行任何您想要的操作

   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"); 

}