刷新页面不能使用treeview在asp.net中工作

时间:2010-05-30 09:37:26

标签: asp.net treeview refresh expand

我正在尝试使用此命令刷新asp.net页面:

<meta http-equiv="Refresh" content="10"/>

在该页面上,我有2个树视图。当我打开页面时刷新工作正常,但是当我点击其中一个树视图并展开它时,刷新停止工作并且页面没有被刷新。

为什么会发生这种情况的任何想法?是否有任何与树视图的连接被扩展?

以下是该页面的完整代码:

public partial class Results : System.Web.UI.Page
{

    protected void Page_Load(object sender, EventArgs e)
    {

    }

    // Function that moves reviewed yellow card to reviewed tree 
    protected void ycActiveTree_SelectedNodeChanged(object sender, EventArgs e)
    {
        ycActiveTree.SelectedNode.Text = "Move To Active"; 
        ycReviewedTree.PopulateNodesFromClient = false;
        ycReviewedTree.Nodes[ycReviewedTree.Nodes.Count - 1].ChildNodes.Add(ycActiveTree.SelectedNode.Parent);
        Application["reviewedTree"] = new ArrayList();
        int count = ((ArrayList)Application["activeTree"]).Count;
        // Move all the nodes from activeTree application to reviewedTree application
        for (int i = 0; Application["activeTree"] != null && i < count; i++)
        {
            ((ArrayList)Application["reviewedTree"]).Add(((ArrayList)Application["activeTree"])[i]);
            ((ArrayList)Application["activeTree"]).RemoveAt(0);
        }
    }

    protected void ycActiveTree_TreeNodePopulate(object sender, TreeNodeEventArgs e)
    {

        if (Application["idList"] != null && e.Node.Depth == 0)
        {

            string[] words = ((String)Application["idList"]).Split(' '); // Yellow Card details
            TreeNode child = new TreeNode("");
            // Go over all the yellow card details and populate the treeview
            for (int i = 1; i < words.Length; i++)
            {
                child.SelectAction = TreeNodeSelectAction.None;
                // Same yellow card
                if (words[i] != "*")
                {
                    // End of details and start of point ip's 
                    if (words[i] == "$")
                    {
                        // Add the yellow card node
                        TreeNode yellowCardNode = new TreeNode(child.Text);
                        yellowCardNode.SelectAction = TreeNodeSelectAction.Expand;

                        e.Node.ChildNodes.Add(yellowCardNode);


                        child.Text = "";
                    }
                    // yellow card details
                    else
                    {
                        child.Text = child.Text + words[i] + " ";
                    }
                }
                // End of yellow card
                else
                {
                    child.PopulateOnDemand = false;
                    child.SelectAction = TreeNodeSelectAction.None;

                    // Populate the yellow card node
                    e.Node.ChildNodes[e.Node.ChildNodes.Count - 1].ChildNodes.Add(child);


                    TreeNode moveChild = new TreeNode("Move To Reviewed");
                    moveChild.PopulateOnDemand = false;
                    moveChild.SelectAction = TreeNodeSelectAction.Select;

                    e.Node.ChildNodes[e.Node.ChildNodes.Count - 1].ChildNodes.Add(moveChild);

                    child = new TreeNode("");


                    Application["activeTree"] = new ArrayList();
                    ((ArrayList)Application["activeTree"]).Add(e.Node.ChildNodes[e.Node.ChildNodes.Count - 1]);
                }
            }
        }
        // If there arent new yellow cards
        else if (Application["activeTree"] != null)
        {
            // Populate the active tree
            for (int i = 0; i < ((ArrayList)Application["activeTree"]).Count; i++)
            {
                e.Node.ChildNodes.Add((TreeNode)((ArrayList)Application["activeTree"])[i]);
            }
        }
        // If there were new yellow cards and nodes that moved from reviewed tree to active tree
        if (Application["idList"] != null && Application["activeTree"] != null && e.Node.ChildNodes.Count != ((ArrayList)Application["activeTree"]).Count)
        {
            for (int i = e.Node.ChildNodes.Count; i < ((ArrayList)Application["activeTree"]).Count; i++)
            {
                e.Node.ChildNodes.Add((TreeNode)((ArrayList)Application["activeTree"])[i]);
            }
        }
        // Nullify the yellow card id's
        Application["idList"] = null;
    }

    protected void ycReviewedTree_SelectedNodeChanged(object sender, EventArgs e)
    {
        ycActiveTree.PopulateNodesFromClient = false;
        ycReviewedTree.SelectedNode.Text = "Move To Reviewed";
        ycActiveTree.Nodes[ycActiveTree.Nodes.Count - 1].ChildNodes.Add(ycReviewedTree.SelectedNode.Parent);
        int count = ((ArrayList)Application["reviewedTree"]).Count;
        // Move all the nodes from reviewedTree application to activeTree application
        for (int i = 0; Application["reviewedTree"] != null && i < count; i++)
        {
            ((ArrayList)Application["activeTree"]).Add(((ArrayList)Application["reviewedTree"])[i]);
            ((ArrayList)Application["reviewedTree"]).RemoveAt(0);
        }
    }

    protected void ycReviewedTree_TreeNodePopulate(object sender, TreeNodeEventArgs e)
    {
        if (Application["reviewedTree"] != null)
        {
            // Populate the reviewed tree
            for (int i = 0; i < ((ArrayList)Application["reviewedTree"]).Count; i++)
            {
                e.Node.ChildNodes.Add((TreeNode)((ArrayList)Application["reviewedTree"])[i]);
            }
        }
    }
}

谢谢,

格雷格

1 个答案:

答案 0 :(得分:0)

通过将树的“EnabledClientScript”属性设置为false来解决此问题。