0
如何在ASP.NET TreeView中点击任何一个子元素时保持背景色?当鼠标点击treeview子元素时保持背景色
如何在ASP.NET TreeView中点击任何一个子元素时保持背景色?当鼠标点击treeview子元素时保持背景色
使用treenodedatabound事件树视图,并添加每个项目onclick事件调用javascript函数做任何你想做
protected void TreeView1_TreeNodeDataBound(object sender, TreeNodeEventArgs e)
{
e.Node.Text = "<span onclick='javascript:MyFunction(this);'>Text</span>";
}
,或者你可以用这种方式
Dim deletenode As New TreeNode("<span onclick=""javascript:confirm('Are you sure you want to delete this ?');"">Delete</span>", "0" & dr("ProjectID"))
新增的项目
Js功能样本
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");
}
您可以提供'javascript:MyFunction(this);功能? – user274139 2010-02-18 06:21:10
function MyFunction(sender) //使用jquery你有html元素(td)你可以从该元素得到任何值,这取决于你的senario //例如你有属性叫做x,持有你想要的值 alert ($(sender).attr(“x”)); //或更改背景颜色 $(sender).css(“background-color”,“blue”); } – 2010-02-18 06:27:39
我不确定语法 sender.style.backgroundColor ='red'; – 2010-02-18 07:01:24