用Hidden控件来取值.
var text = document.getElementById("TreeView1").getChildren().getAttribute("NodeData");
document.all.hidden1.value += text;
在后台代码里用:
String text = Request.Form["hidden1"].ToString();
节点的NavigateUrl = "javascript:clicknode('login.aspx')"
在页面中用javascript写上clicknode函数,在要改变的右边页面做一个
这样点击TreeView上的节点时,通过NavigateUrl属性转到执行客户端的javascript脚本程序,达到左边导航栏不刷新,右边页面的变换。
function tree_oncheck()
{
var data="";
var node=TreeView.getTreeNode(event.treeNodeIndex);
var Pchecked=node.getAttribute("checked");
setcheck(node,Pchecked);
//遍利整个树读取选中结点的值 document.getElementById("txtData").value =""; var ChildNode = new Array(); ChildNode = TreeView.getChildren(); for(var i = 0 ; i < parseInt(ChildNode.length) ; i++) { //alert(ChildNode[i].getAttribute("id")); getValue(ChildNode[i]) } document.getElementById("txtData").value = document.getElementById("txtData").value.substring(0, document.getElementById("txtData").value.length-1); }//读取选中结点的值function getValue(node) { var ChildNode = new Array(); ChildNode = node.getChildren(); if (parseInt(ChildNode.length) != 0) { for (var i = 0; i < ChildNode.length; i++) { var cNode = ChildNode[i]; if (cNode.getAttribute("checked") == true) { document.getElementById("txtData").value += cNode.getAttribute("id").substring(1,cNode.getAttribute("id").length)+","; } if (parseInt(cNode.getChildren().length) != 0) getValue(cNode); } }}//全选function setcheck(node, Pc) { var ChildNode = new Array(); ChildNode = node.getChildren(); if (parseInt(ChildNode.length) != 0) { for (var i = 0; i < ChildNode.length; i++) { var cNode = ChildNode[i]; if (cNode.getAttribute("checked") != Pc) { if (parseInt(cNode.getChildren().length) != 0) setcheck(cNode, Pc); cNode.setAttribute("checked", Pc); //TreeView.queueEvent('oncheck', cNode.getNodeIndex()); } } }}
本文作者:佚名 来源:本站原创
CIO之家 www.ciozj.com 微信公众号:imciow