[原创]在TreeView中如何实现第一层的节点,第二层的节点,点击的时候都不PostBack,第三层的节点点击的时候,能够PostBack
发送者 skytear | 发送时间 2005-4-26 19:18:24 | 删除 | 回复 | |
内容 | 上次回一个帖子是一个人的如何点击某个节点后再去展开其子节点,你也到回复。 后来自己做也碰到问题: TreeView不能PostBack,那么当其先展开了三层的节点以后,点击某个在三层的节点上面要去展开该节点下面的子节点,整个树不能PostBack了。 有没有办法可以实现: 第一层的节点,第二层的节点,点击的时候都不PostBack,第三层的节点点击的时候,能够PostBack 不能用连接来做。因为试了不可以。你有什么建议吗?多谢! |
<script language="javascript">
function setV()
{
var cIndex=TreeView2.clickedNodeIndex;
var tmp=cIndex.split(".");
if (tmp.length==3)
{
var pNode=TreeView2.getTreeNode(cIndex);
document.all.Hidden1.value =pNode.getAttribute("Text");
document.Form1.submit();
}
}
</script>
function setV()
{
var cIndex=TreeView2.clickedNodeIndex;
var tmp=cIndex.split(".");
if (tmp.length==3)
{
var pNode=TreeView2.getTreeNode(cIndex);
document.all.Hidden1.value =pNode.getAttribute("Text");
document.Form1.submit();
}
}
</script>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<iewc:TreeView id="TreeView2" style="Z-INDEX: 101; LEFT: 264px; POSITION: absolute; TOP: 176px"
runat="server">
<iewc:TreeNode Text="Node0">
<iewc:TreeNode Text="Node2">
<iewc:TreeNode Text="Node4"></iewc:TreeNode>
<iewc:TreeNode Text="Node5"></iewc:TreeNode>
</iewc:TreeNode>
<iewc:TreeNode Text="Node3"></iewc:TreeNode>
</iewc:TreeNode>
<iewc:TreeNode Text="Node1"></iewc:TreeNode>
</iewc:TreeView><INPUT id="Hidden1" style="Z-INDEX: 102; LEFT: 176px; POSITION: absolute; TOP: 56px" type="hidden"
name="Hidden1" runat="server">
</form>
</body>
<form id="Form1" method="post" runat="server">
<iewc:TreeView id="TreeView2" style="Z-INDEX: 101; LEFT: 264px; POSITION: absolute; TOP: 176px"
runat="server">
<iewc:TreeNode Text="Node0">
<iewc:TreeNode Text="Node2">
<iewc:TreeNode Text="Node4"></iewc:TreeNode>
<iewc:TreeNode Text="Node5"></iewc:TreeNode>
</iewc:TreeNode>
<iewc:TreeNode Text="Node3"></iewc:TreeNode>
</iewc:TreeNode>
<iewc:TreeNode Text="Node1"></iewc:TreeNode>
</iewc:TreeView><INPUT id="Hidden1" style="Z-INDEX: 102; LEFT: 176px; POSITION: absolute; TOP: 56px" type="hidden"
name="Hidden1" runat="server">
</form>
</body>
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TreeView2.Attributes.Add("onclick", "javascript:setV();")
Response.Write(Hidden1.Value)
End Sub
TreeView2.Attributes.Add("onclick", "javascript:setV();")
Response.Write(Hidden1.Value)
End Sub
你可以把Response.Write(Hidden1.Value) 这句换成从数据库检索数据得到它(第三层的节点)的子节点