protected void treeElem_TreeNodePopulate(object sender, TreeNodeEventArgs e) { e.Node.ChildNodes.Clear(); e.Node.PopulateOnDemand = false; int nodeId = ValidationHelper.GetInteger(e.Node.Value, 0); TreeNode node = TreeProvider.SelectSingleNode(nodeId); // Check explore tree permission for current node bool userHasExploreTreePermission = (MembershipContext.AuthenticatedUser.IsAuthorizedPerDocument(node, NodePermissionsEnum.ExploreTree) == AuthorizationResultEnum.Allowed); if (userHasExploreTreePermission) { SiteMapNodeCollection childNodes = MapProvider.GetChildNodes(nodeId); int index = 0; foreach (TreeSiteMapNode childNode in childNodes) { int childNodeId = (int)childNode.NodeData["NodeID"]; if (childNodeId != nodeId) { System.Web.UI.WebControls.TreeNode newNode = CreateNode(childNode, index, true); e.Node.ChildNodes.Add(newNode); index++; } } } else { // Add 'access denied node' System.Web.UI.WebControls.TreeNode tempNode = new System.Web.UI.WebControls.TreeNode(); tempNode.Text = GetString("ContentTree.ExploreChildsDenied"); tempNode.NavigateUrl = (DeniedNodePostback ? mBasePath + "#" : string.Empty); e.Node.ChildNodes.Add(tempNode); } }
/// <summary> /// On populate create child nodes. /// </summary> protected void treeElem_TreeNodePopulate(object sender, TreeNodeEventArgs e) { e.Node.ChildNodes.Clear(); e.Node.PopulateOnDemand = false; int postId = ValidationHelper.GetInteger(e.Node.Value, 0); // Set the ForumID if not set already if (ForumContext.ForumID == 0) { ForumPostInfo postInfo = ForumPostInfoProvider.GetForumPostInfo(postId); if (postInfo != null) { ForumContext.ForumID = postInfo.PostForumID; ForumID = postInfo.PostForumID; } } // Get child nodes SiteMapNodeCollection childNodes = MapProvider.GetChildNodes(postId, RegularLoad); int index = 0; foreach (ForumPostTreeNode childNode in childNodes) { int childNodeId = (int)((DataRow)childNode.ItemData)["PostID"]; if (childNodeId != postId) { TreeNode newNode = CreateNode(childNode, index); bool? originalExpanded = newNode.Expanded; // Force node to expand and load child posts if (DetailModeIE) { newNode.PopulateOnDemand = true; newNode.Expanded = true; } e.Node.ChildNodes.Add(newNode); // Restore original expanded state if (DetailModeIE) { newNode.Expanded = originalExpanded; } index++; } // Ensure there is only one 'click here for more' item if (UseMaxPostNodes && (MaxPostNodes > 0) && (index > MaxPostNodes)) { break; } } }