Monday, 26 September 2011

how to disable the Selected tree Node in Asp.net pages or SharePoint 2010 Webpart



We should Not allow the user to click twice on the same node.because it cause post back

Solution:
 - -> Pass the root Node value as a parameter
// Method for Going all Nodes and setting the Enable and disable
    protected void ParseNode(TreeNode tnRootNode)
        {
            if (tnRootNode.Selected)
            {
                tnRootNode.SelectAction = TreeNodeSelectAction.None;
            }
            else
            {
                tnRootNode.SelectAction = TreeNodeSelectAction.Select;
            }
              
            foreach (TreeNode child in tnRootNode.ChildNodes)
            {
                if (child.ChildNodes.Count > 0)
                {
                    ParseNode(child);
                }
                else
                {

                    if (child.Selected)
                    {
                        child.SelectAction = TreeNodeSelectAction.None;
                    }
                    else
                    {
                        child.SelectAction = TreeNodeSelectAction.Select;
                    }
                }
            }
         
        }





No comments:

Post a Comment