用js或者jQuery,这里给一个例子:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="CSharp.WebForm1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.0.min.js"></script>
<script type="text/javascript">
$(function ()
{
$("table input[type='checkbox']").click(function ()
{
var result = $(this).attr("checked");
if (result == "checked") {
alert($(this).next().html()); //弹出选中框的文字
}
});
})
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TreeView ID="TreeView1" runat="server" ImageSet="Msdn" NodeIndent="10" ShowCheckBoxes="All">
<HoverNodeStyle BackColor="#CCCCCC" BorderColor="#888888" BorderStyle="Solid" Font-Underline="True" />
<Nodes>
<asp:TreeNode Text="父亲节点1" Value="父亲节点1">
<asp:TreeNode Text="儿子节点1" Value="儿子节点1"></asp:TreeNode>
<asp:TreeNode Text="儿子节点2" Value="儿子节点2"></asp:TreeNode>
</asp:TreeNode>
<asp:TreeNode Text="父亲节点2" Value="父亲节点2"></asp:TreeNode>
</Nodes>
<NodeStyle Font-Names="Verdana" Font-Size="8pt" ForeColor="Black" HorizontalPadding="5px" NodeSpacing="1px" VerticalPadding="2px" />
<ParentNodeStyle Font-Bold="False" />
<SelectedNodeStyle BackColor="White" BorderColor="#888888" BorderStyle="Solid" BorderWidth="1px" Font-Underline="False" HorizontalPadding="3px" VerticalPadding="1px" />
</asp:TreeView>
</div>
</form>
</body>
</html>
下载MSDN桌面工具(Vista,Win7)
我的博客园
慈善点击,点击此处