Example #1
0
        private void GenerateTreeByLevel(int nodesPerLevel)
        {
            if (nodesPerLevel > 50)
            {
                this.divConsole.InnerHtml += (string.Format("{0} nodes, too many, isn't it? :-)", nodesPerLevel * nodesPerLevel));

                //FlashMessage.SetFlash( string.Format( "{0} nodes, too many, isn't it? :-)", nodesPerLevel * nodesPerLevel ), FlashMessage.FlashMessageType.Error );
                return;
            }

            for (int i = 0; i < nodesPerLevel; i++)
            {
                ASTreeViewNode l1 = new ASTreeViewNode(string.Format("Node-L{0}-{1}", 1, i));
                this.astvMyTree.RootNode.ChildNodes.Add(l1);

                for (int j = 0; j < nodesPerLevel; j++)
                {
                    ASTreeViewNode l2 = new ASTreeViewNode(string.Format("Node-L{0}-{1}-{2}", 2, i, j));
                    l1.ChildNodes.Add(l2);

                    /*
                     * for( int k = 0; k < nodesPerLevel; k++ )
                     * {
                     *  ASTreeViewNode l3 = new ASTreeViewNode( string.Format( "Node-{0}-{1}", 3, k ) );
                     *  l2.ChildNodes.Add( l3 );
                     * }*/
                }
            }

            //FlashMessage.SetFlash( string.Format( "{0} nodes generated.", nodesPerLevel * nodesPerLevel ) );

            this.divConsole.InnerHtml += (string.Format(">>{0} nodes generated.<br />", nodesPerLevel * nodesPerLevel));
        }
Example #2
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            /*
             * if (String.IsNullOrEmpty(tbItem.Text))
             *  return;
             */

            string maxSql = string.Format("SELECT MAX(productId) from ProductsTree");
            int    max    = (int)OleDbHelper.ExecuteScalar(base.NorthWindConnectionString, CommandType.Text, maxSql);
            int    newId  = max + 1;

            OleDbHelper.ExecuteNonQuery(base.NorthWindConnectionString, CommandType.Text, string.Format("INSERT INTO ProductsTree (ProductId, ProductName, ParentId, Username) VALUES({0},'{1}',{3},'{2}')", newId, "Untitled", Session["UserName"].ToString(), ddlRoot1.SelectedValue));
            String qry = "SELECT SUBSTRING([ProductName], 1, CASE CHARINDEX(CHAR(10), [ProductName]) WHEN 0 THEN LEN([ProductName]) ELSE CHARINDEX(char(10), [ProductName]) - 1 END) as ProductName from [ProductsTree] where ProductID=" + newId.ToString();

            ASTreeViewNode newNode = new ASTreeViewNode((string)OleDbHelper.ExecuteScalar(base.NorthWindConnectionString, CommandType.Text, qry), newId.ToString());
            List <KeyValuePair <string, string> > attrib = new List <KeyValuePair <string, string> >();

            ASTreeViewNode rootNode = astvMyTree1.FindByValue(ddlRoot1.Text);

            rootNode.AppendChild(newNode);

            XmlDocument doc = astvMyTree1.GetTreeViewXML();

            doc.Save(Server.MapPath("~/" + ddlRoot1.SelectedValue + ".xml"));
            BindData();
        }
Example #3
0
        protected void btnAdd2_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(tbItem2.Text))
            {
                return;
            }

            string maxSql = string.Format("select max( productId ) from ProductsTree");
            int    max    = (int)OleDbHelper.ExecuteScalar(base.NorthWindConnectionString, CommandType.Text, maxSql);
            int    newId  = max + 1;

            OleDbHelper.ExecuteNonQuery(base.NorthWindConnectionString, CommandType.Text, string.Format("INSERT INTO ProductsTree (ProductId, ProductName, ParentId,Username) VALUES({0}, '{1}', 0,'{2}')", newId, tbItem2.Text, Session["UserName"].ToString()));
            String qry = "select SUBSTRING([ProductName], 1, CASE CHARINDEX(CHAR(10), [ProductName]) WHEN 0 THEN LEN([ProductName]) ELSE CHARINDEX(char(10), [ProductName]) - 1 END) as ProductName from [ProductsTree] where ProductID=" + newId.ToString();


            ASTreeViewNode newNode = new ASTreeViewNode((string)OleDbHelper.ExecuteScalar(base.NorthWindConnectionString, CommandType.Text, qry), newId.ToString());

            ASTreeViewNode rootNode = astvMyTree2.FindByValue("root");

            rootNode.AppendChild(newNode);
            XmlDocument doc = astvMyTree2.GetTreeViewXML();

            doc.Save(Server.MapPath("~/" + Session["UserName"] + ".xml"));
            BindData();
        }
		protected override void Render( HtmlTextWriter writer )
		{
			if( Request.QueryString["t"] == "ajaxAdd" )
			{
				string addNodeText = HttpUtility.UrlDecode( Request.QueryString["addNodeText"] );
				int parentNodeValue = int.Parse( HttpUtility.UrlDecode( Request.QueryString["parentNodeValue"] ) );

				string maxSql = "select max( productId ) from products";
				int max = (int)OleDbHelper.ExecuteScalar( base.NorthWindConnectionString, CommandType.Text, maxSql );
				int newId = max + 1;

				string sql = string.Format( @"INSERT INTO products( productid, Discontinued, productname, parentid ) values( {0} ,0, '{1}', {2})"
					, max + 1, addNodeText.Replace( "'", "''" ), parentNodeValue );

				int i = OleDbHelper.ExecuteNonQuery( base.NorthWindConnectionString, CommandType.Text, sql );

				ASTreeViewNode root = new ASTreeViewNode( "root" );

				ASTreeViewLinkNode node = new ASTreeViewLinkNode( addNodeText, newId.ToString() );
				node.NavigateUrl = "#";
				node.AdditionalAttributes.Add( new KeyValuePair<string, string>( "onclick", "return false;" ) );

				root.AppendChild( node );

				HtmlGenericControl ulRoot = new HtmlGenericControl( "ul" );
				astvMyTree.TreeViewHelper.ConvertTree( ulRoot, root, false );
				foreach( Control c in ulRoot.Controls )
					c.RenderControl( writer );

				/*
				foreach( DataRow dr in dt.Rows )
				{
					string productName = dr["ProductName"].ToString();
					string productId = dr["ProductID"].ToString();
					string parentId = dr["ParentID"].ToString();
					int childNodesCount = 0;
					if( !string.IsNullOrEmpty( dr["ChildNodesCount"].ToString() ) )
						childNodesCount = int.Parse( dr["ChildNodesCount"].ToString() );

					ASTreeViewLinkNode node = new ASTreeViewLinkNode( productName, productId );
					node.VirtualNodesCount = childNodesCount;
					node.VirtualParentKey = productId;
					node.IsVirtualNode = childNodesCount > 0;
					node.NavigateUrl = "#";
					node.AdditionalAttributes.Add( new KeyValuePair<string, string>( "onclick", "return false;" ) );

					root.AppendChild( node );
				}



				HtmlGenericControl ulRoot = new HtmlGenericControl( "ul" );
				astvMyTree.TreeViewHelper.ConvertTree( ulRoot, root, false );
				foreach( Control c in ulRoot.Controls )
					c.RenderControl( writer );*/
			}
			else
				base.Render( writer );

		}
        private void GenerateTree()
        {
            //bind data from data table
            //string path = System.AppDomain.CurrentDomain.BaseDirectory;
            //string connStr = string.Format( "Provider=Microsoft.Jet.OLEDB.4.0;Data source={0}db\\NorthWind.mdb", path );

            DataSet ds = OleDbHelper.ExecuteDataset(base.NorthWindConnectionString, CommandType.Text, "select * from [Products]");

            ASTreeViewDataTableColumnDescriptor descripter = new ASTreeViewDataTableColumnDescriptor("ProductName"
                                                                                                     , "ProductID"
                                                                                                     , "ParentID");

            this.astvMyTree.DataSourceDescriptor = descripter;
            this.astvMyTree.DataSource           = ds.Tables[0];
            this.astvMyTree.DataBind();


            StringBuilder sb = new StringBuilder();

            foreach (ASTreeViewNode node in this.astvMyTree.RootNode.ChildNodes[0].ChildNodes)
            {
                ASTreeViewNode nextNode     = GetNextNode(node);
                ASTreeViewNode previousNode = GetPreviousNode(node);
                sb.Append(">>[cur Node]:" + node.NodeText
                          + "[previous]" + (previousNode == null ? "%NULL%" : previousNode.NodeText)
                          + "[next]:" + (nextNode == null ? "%NULL%" : nextNode.NodeText) + "<br />");
            }

            //this.divConsole.InnerHtml = sb.ToString();
        }
Example #6
0
    private ASTreeViewNode GetASTNode(string status)
    {
        CodeMaster     codeMaster = TheCodeMasterMgr.GetCachedCodeMaster(BusinessConstants.CODE_MASTER_STATUS, status);
        ASTreeViewNode ast        = new ASTreeViewNode(codeMaster.Description, codeMaster.Value);

        return(ast);
    }
Example #7
0
        protected void btnUpdat_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(tbItem.Text))
            {
                return;
            }

            if (String.IsNullOrEmpty(lblRoot.Text))
            {
                return;
            }

            OleDbHelper.ExecuteNonQuery(base.NorthWindConnectionString, CommandType.Text, string.Format("UPDATE ProductsTree set ProductName='{0}' where ProductId={1}", tbItem.Text, lblRoot.Text));
            String qry = "SELECT SUBSTRING([ProductName], 1, CASE CHARINDEX(CHAR(10), [ProductName]) WHEN 0 THEN LEN([ProductName]) ELSE CHARINDEX(char(10), [ProductName]) - 1 END) as ProductName from [ProductsTree] where ProductID=" + lblRoot.Text;

            ASTreeViewNode selectedNode = astvMyTree1.FindByValue(lblRoot.Text);

            selectedNode.NodeText = (string)OleDbHelper.ExecuteScalar(base.NorthWindConnectionString, CommandType.Text, qry);

            prevText.Text = tbItem.Text;

            XmlDocument doc = astvMyTree1.GetTreeViewXML();

            doc.Save(Server.MapPath("~/" + ddlRoot1.SelectedValue + ".xml"));
            BindData();
        }
Example #8
0
        protected override void Render(HtmlTextWriter writer)
        {
            if (Request.QueryString["t"] == "ajaxAdd")
            {
                string addNodeText     = HttpUtility.UrlDecode(Request.QueryString["addNodeText"]);
                int    parentNodeValue = int.Parse(HttpUtility.UrlDecode(Request.QueryString["parentNodeValue"]));

                if (addNodeText.ToLower().IndexOf("a") >= 0)
                {
                    ASTreeViewNode root = new ASTreeViewNode("root");

                    ASTreeViewLinkNode node = new ASTreeViewLinkNode("[Server Said]:You cannot add node with nodetext containing letter 'a'", "failed");
                    node.AdditionalAttributes.Add(new KeyValuePair <string, string>("addfailed", "true"));

                    root.AppendChild(node);

                    HtmlGenericControl ulRoot = new HtmlGenericControl("ul");
                    astvMyTree.TreeViewHelper.ConvertTree(ulRoot, root, false);
                    foreach (Control c in ulRoot.Controls)
                    {
                        c.RenderControl(writer);
                    }
                }
                else
                {
                    string maxSql = "select max( productId ) from products";
                    int    max    = (int)OleDbHelper.ExecuteScalar(base.NorthWindConnectionString, CommandType.Text, maxSql);
                    int    newId  = max + 1;

                    string sql = string.Format(@"INSERT INTO products( productid, Discontinued, productname, parentid ) values( {0} ,0, '{1}', {2})"
                                               , max + 1, addNodeText.Replace("'", "''"), parentNodeValue);

                    int i = OleDbHelper.ExecuteNonQuery(base.NorthWindConnectionString, CommandType.Text, sql);

                    ASTreeViewNode root = new ASTreeViewNode("root");

                    ASTreeViewLinkNode node = new ASTreeViewLinkNode(addNodeText, newId.ToString());
                    node.NavigateUrl = "#";
                    node.AdditionalAttributes.Add(new KeyValuePair <string, string>("onclick", "return false;"));

                    root.AppendChild(node);

                    HtmlGenericControl ulRoot = new HtmlGenericControl("ul");
                    astvMyTree.TreeViewHelper.ConvertTree(ulRoot, root, false);
                    foreach (Control c in ulRoot.Controls)
                    {
                        c.RenderControl(writer);
                    }
                }
            }
            else
            {
                base.Render(writer);
            }
        }
Example #9
0
        protected void astvMyTree2_OnSelectedNodeChanged(object src, ASTreeViewNodeSelectedEventArgs e)
        {
            //tb1.Text = e.NodeText;
            ASTreeViewNode selectedNode = astvMyTree2.GetSelectedNode();

            if (selectedNode != null)
            {
                lblRoot2.Text = selectedNode.NodeValue;
                tbItem2.Text  = (string)OleDbHelper.ExecuteScalar(base.NorthWindConnectionString, CommandType.Text, "select ProductName from ProductsTree where ProductID=" + lblRoot2.Text);
            }
        }
        protected void btnFindByText_Click(object sender, EventArgs e)
        {
            ASTreeViewNode node   = this.astvMyTree.FindByText(this.txtTarget.Text);
            string         result = "Nothing found.";

            if (node != null)
            {
                result = string.Format("Node Found! [Text]:{0} [Value]:{1}", node.NodeText, node.NodeValue);
            }

            this.divConsole.InnerHtml += (result + "<br />");
        }
        private void IterateNode(ASTreeViewNode node, ref string nodeString)
        {
            if (!node.Equals(this.astvMyTree.RootNode))
            {
                nodeString += ("[NODE:]" + node.NodeText + "[PARENT-NODE:]" + node.ParentNode.NodeText + "<br />");
            }

            foreach (ASTreeViewNode child in node.ChildNodes)
            {
                //recursive call
                IterateNode(child, ref nodeString);
            }
        }
		protected override void Render( HtmlTextWriter writer )
		{
			if( Request.QueryString["t"] == "ajaxAdd" )
			{
				string addNodeText = HttpUtility.UrlDecode( Request.QueryString["addNodeText"] );
				int parentNodeValue = int.Parse( HttpUtility.UrlDecode( Request.QueryString["parentNodeValue"] ) );

				if( addNodeText.ToLower().IndexOf( "a" ) >= 0 )
				{
					ASTreeViewNode root = new ASTreeViewNode( "root" );

					ASTreeViewLinkNode node = new ASTreeViewLinkNode( "[Server Said]:You cannot add node with nodetext containing letter 'a'", "failed" );
					node.AdditionalAttributes.Add( new KeyValuePair<string, string>( "addfailed", "true" ) );

					root.AppendChild( node );

					HtmlGenericControl ulRoot = new HtmlGenericControl( "ul" );
					astvMyTree.TreeViewHelper.ConvertTree( ulRoot, root, false );
					foreach( Control c in ulRoot.Controls )
						c.RenderControl( writer );
				}
				else
				{
					string maxSql = "select max( productId ) from products";
					int max = (int)OleDbHelper.ExecuteScalar( base.NorthWindConnectionString, CommandType.Text, maxSql );
					int newId = max + 1;

					string sql = string.Format( @"INSERT INTO products( productid, Discontinued, productname, parentid ) values( {0} ,0, '{1}', {2})"
						, max + 1, addNodeText.Replace( "'", "''" ), parentNodeValue );

					int i = OleDbHelper.ExecuteNonQuery( base.NorthWindConnectionString, CommandType.Text, sql );

					ASTreeViewNode root = new ASTreeViewNode( "root" );

					ASTreeViewLinkNode node = new ASTreeViewLinkNode( addNodeText, newId.ToString() );
					node.NavigateUrl = "#";
					node.AdditionalAttributes.Add( new KeyValuePair<string, string>( "onclick", "return false;" ) );

					root.AppendChild( node );

					HtmlGenericControl ulRoot = new HtmlGenericControl( "ul" );
					astvMyTree.TreeViewHelper.ConvertTree( ulRoot, root, false );
					foreach( Control c in ulRoot.Controls )
						c.RenderControl( writer );
				}
			}
			else
				base.Render( writer );

		}
        public ASTreeViewNode GetNextNode( ASTreeViewNode curNode )
        {
            if( curNode.ParentNode == null )
                return null;

            for( int i = 0; i < curNode.ParentNode.ChildNodes.Count; i++ )
            {
                if( curNode.ParentNode.ChildNodes[i] == curNode )
                {
                    if( ( i + 1 ) <= ( curNode.ParentNode.ChildNodes.Count - 1 ) )
                        return curNode.ParentNode.ChildNodes[i + 1];
                }
            }

            return null;
        }
        public ASTreeViewNode GetPreviousNode( ASTreeViewNode curNode )
        {
            if( curNode.ParentNode == null )
                return null;

            for( int i = 0; i < curNode.ParentNode.ChildNodes.Count; i++ )
            {
                if( curNode.ParentNode.ChildNodes[i] == curNode )
                {
                    if( i > 0 )
                        return curNode.ParentNode.ChildNodes[i - 1];
                }
            }

            return null;
        }
Example #15
0
        protected void astvMyTree_OnSelectedNodeChanged(object src, ASTreeViewNodeSelectedEventArgs e)
        {
            //tb1.Text = e.NodeText;
            ASTreeViewNode selectedNode = astvMyTree1.GetSelectedNode();

            if (selectedNode != null)
            {
                lblRoot.Text = selectedNode.NodeValue;

                tbItem.Text       = (string)OleDbHelper.ExecuteScalar(base.NorthWindConnectionString, CommandType.Text, "select ProductName from ProductsTree where ProductID=" + lblRoot.Text);
                btnUpdate.Enabled = cekOwner(ddlRoot1.SelectedValue);
                if (btnUpdate.Enabled)
                {
                    btnUpdate.Enabled = cekOwner(lblRoot.Text);
                }
            }
        }
        protected void btnGetSelectedNode_Click(object sender, EventArgs e)
        {
            string toConsole = string.Empty;

            ASTreeViewNode selectedNode = astvMyTree.GetSelectedNode();

            if (selectedNode == null)
            {
                toConsole = ">>no node selected.";
            }
            else
            {
                toConsole = string.Format(">>node selected: text:{0} value:{1}", selectedNode.NodeText, selectedNode.NodeValue);
            }

            this.divConsole.InnerHtml += (toConsole + "<br />");
        }
        public ASTreeViewNode GetNextNode(ASTreeViewNode curNode)
        {
            if (curNode.ParentNode == null)
            {
                return(null);
            }

            for (int i = 0; i < curNode.ParentNode.ChildNodes.Count; i++)
            {
                if (curNode.ParentNode.ChildNodes[i] == curNode)
                {
                    if ((i + 1) <= (curNode.ParentNode.ChildNodes.Count - 1))
                    {
                        return(curNode.ParentNode.ChildNodes[i + 1]);
                    }
                }
            }

            return(null);
        }
        public ASTreeViewNode GetPreviousNode(ASTreeViewNode curNode)
        {
            if (curNode.ParentNode == null)
            {
                return(null);
            }

            for (int i = 0; i < curNode.ParentNode.ChildNodes.Count; i++)
            {
                if (curNode.ParentNode.ChildNodes[i] == curNode)
                {
                    if (i > 0)
                    {
                        return(curNode.ParentNode.ChildNodes[i - 1]);
                    }
                }
            }

            return(null);
        }
        protected void btnGetSelectedNode_Click(object sender, EventArgs e)
        {
            //if( !Page.IsValid )
            //	return;
            ASTreeViewNode node      = this.astvMyTree2.GetSelectedNode();
            string         toConsole = string.Empty;

            if (node == null)
            {
                toConsole = "nothing selected";
            }
            else
            {
                toConsole += (node.NodeText);

                toConsole = toConsole.Substring(0, toConsole.Length - 1);

                //toConsole = node.NodeText;//XmlHelper.GetFormattedXmlString( this.astvMyTree.GetTreeViewXML(), true );
            }
            this.divConsole.InnerHtml += (string.Format(">>Selected node: <pre style='padding-left:20px;'>{0}</pre>", toConsole.ToString()));
        }
        private void GenerateTree2()
        {
            string para = "= 1";

            string sql = @"SELECT p1.[ProductID] as ProductID, p1.[ProductName] as ProductName, p3.childNodesCount as ChildNodesCount, p1.[ParentID] as ParentID
FROM [Products] p1
INNER JOIN 
(
	SELECT COUNT(*) AS childNodesCount , p2.[ParentID] AS pId 
	FROM [Products] p2
	GROUP BY p2.[ParentID]
) p3
ON p1.[ProductID] = p3.pId
WHERE p1.[ParentID] " + para;

            DataTable dt = OleDbHelper.ExecuteDataset(base.NorthWindConnectionString, CommandType.Text, sql).Tables[0];

            ASTreeViewNode root = this.astvMyTree2.RootNode;

            foreach (DataRow dr in dt.Rows)
            {
                string productName     = dr["ProductName"].ToString();
                string productId       = dr["ProductID"].ToString();
                string parentId        = dr["ParentID"].ToString();
                int    childNodesCount = int.Parse(dr["ChildNodesCount"].ToString());

                ASTreeViewLinkNode node = new ASTreeViewLinkNode(productName, productId);
                node.VirtualNodesCount = childNodesCount;
                node.VirtualParentKey  = productId;
                node.IsVirtualNode     = childNodesCount > 0;
                node.NavigateUrl       = "#";
                //List<KeyValuePair<string, string>> attrs = new List<KeyValuePair<string, string>>();
                node.AdditionalAttributes.Add(new KeyValuePair <string, string>("onclick", "return false;"));
                //node.AdditionalAttributes = attrs;

                root.AppendChild(node);
            }
        }
Example #21
0
    protected void Page_Load(object sender, EventArgs e)
    {
        this.tbFlow.ServiceParameter = "string:" + this.CurrentUser.Code;

        if (!IsPostBack)
        {
            ASTreeViewNode astCREATE = this.GetASTNode(BusinessConstants.CODE_MASTER_STATUS_VALUE_CREATE);
            astCREATE.CheckedState = ASTreeViewCheckboxState.Checked;
            this.astvMyTree.RootNode.AppendChild(astCREATE);

            ASTreeViewNode astSUBMIT = this.GetASTNode(BusinessConstants.CODE_MASTER_STATUS_VALUE_SUBMIT);
            astSUBMIT.CheckedState = ASTreeViewCheckboxState.Checked;
            this.astvMyTree.RootNode.AppendChild(astSUBMIT);

            ASTreeViewNode astCANCEL = this.GetASTNode(BusinessConstants.CODE_MASTER_STATUS_VALUE_CANCEL);
            this.astvMyTree.RootNode.AppendChild(astCANCEL);

            this.astvMyTree.InitialDropdownText = BusinessConstants.CODE_MASTER_STATUS_VALUE_CREATE + "," + BusinessConstants.CODE_MASTER_STATUS_VALUE_SUBMIT;
            this.astvMyTree.DropdownText        = BusinessConstants.CODE_MASTER_STATUS_VALUE_CREATE + "," + BusinessConstants.CODE_MASTER_STATUS_VALUE_SUBMIT;

            this.tbStartDate.Text = DateTime.Today.ToString("yyyy-MM-dd");
            this.tbEndDate.Text   = DateTime.Today.AddDays(1).ToString("yyyy-MM-dd");
        }
    }
Example #22
0
 private ASTreeViewNode GetASTNode(string status)
 {
     CodeMaster codeMaster = TheCodeMasterMgr.GetCachedCodeMaster(BusinessConstants.CODE_MASTER_STATUS, status);
     ASTreeViewNode ast = new ASTreeViewNode(codeMaster.Description, codeMaster.Value);
     return ast;
 }
        private void IterateNode( ASTreeViewNode node, ref string nodeString )
        {
            if( !node.Equals( this.astvMyTree.RootNode ) )
                nodeString += ( "[NODE:]" + node.NodeText + "[PARENT-NODE:]" + node.ParentNode.NodeText + "<br />" );

            foreach( ASTreeViewNode child in node.ChildNodes )
            {
                //recursive call
                IterateNode( child, ref nodeString );
            }
        }
        protected override void Render( HtmlTextWriter writer )
        {
            if( Request.QueryString["t1"] == "ajaxLoad" )
            {
                string virtualParentKey = Request.QueryString["virtualParentKey"];

                string para = string.Empty;// "= 1";
                if( virtualParentKey == null )
                    para = " is NULL";
                else
                    para = "=" + virtualParentKey;

                string sql = @"SELECT p1.[ProductID] as ProductID, p1.[ProductName] as ProductName, p1.[ParentID] as ParentID, p3.childNodesCount as ChildNodesCount
            FROM [Products] p1
            LEFT OUTER JOIN
            (
            SELECT COUNT(*) AS childNodesCount , p2.[ParentID] AS pId
            FROM [Products] p2
            GROUP BY p2.[ParentID]
            ) p3
            ON p1.[ProductID] = p3.pId
            WHERE p1.[ParentID] " + para;

                DataTable dt = OleDbHelper.ExecuteDataset( base.NorthWindConnectionString, CommandType.Text, sql ).Tables[0];

                ASTreeViewNode root = new ASTreeViewNode( "root" );

                foreach( DataRow dr in dt.Rows )
                {
                    string productName = dr["ProductName"].ToString();
                    string productId = dr["ProductID"].ToString();
                    string parentId = dr["ParentID"].ToString();
                    int childNodesCount = 0;
                    if( !string.IsNullOrEmpty( dr["ChildNodesCount"].ToString() ) )
                        childNodesCount = int.Parse( dr["ChildNodesCount"].ToString() );

                    ASTreeViewLinkNode node = new ASTreeViewLinkNode( productName, productId );
                    node.VirtualNodesCount = childNodesCount;
                    node.VirtualParentKey = productId;
                    node.IsVirtualNode = childNodesCount > 0;
                    node.NavigateUrl = "#";
                    node.AdditionalAttributes.Add( new KeyValuePair<string, string>( "onclick", "return false;" ) );

                    root.AppendChild( node );
                }

                HtmlGenericControl ulRoot = new HtmlGenericControl( "ul" );
                astvMyTree2.TreeViewHelper.ConvertTree( ulRoot, root, false );
                foreach( Control c in ulRoot.Controls )
                    c.RenderControl( writer );
            }
            else if( Request.QueryString["t2"] == "ajaxAdd" )
            {
                string addNodeText = Request.QueryString["addNodeText"];
                int parentNodeValue = int.Parse( Request.QueryString["parentNodeValue"] );

                string maxSql = "select max( productId ) from products";
                int max = (int)OleDbHelper.ExecuteScalar( base.NorthWindConnectionString, CommandType.Text, maxSql );
                int newId = max + 1;

                string sql = string.Format( @"INSERT INTO products( productid, Discontinued, productname, parentid ) values( {0} ,0, '{1}', {2})"
                    , max + 1, addNodeText.Replace( "'", "''" ), parentNodeValue );

                int i = OleDbHelper.ExecuteNonQuery( base.NorthWindConnectionString, CommandType.Text, sql );

                ASTreeViewNode root = new ASTreeViewNode( "root" );

                ASTreeViewLinkNode node = new ASTreeViewLinkNode( addNodeText, newId.ToString() );
                node.NavigateUrl = "#";
                node.AdditionalAttributes.Add( new KeyValuePair<string, string>( "onclick", "return false;" ) );

                root.AppendChild( node );

                HtmlGenericControl ulRoot = new HtmlGenericControl( "ul" );
                astvMyTree2.TreeViewHelper.ConvertTree( ulRoot, root, false );
                foreach( Control c in ulRoot.Controls )
                    c.RenderControl( writer );
            }
            else
                base.Render( writer );
        }
        protected override void Render(HtmlTextWriter writer)
        {
            if (Request.QueryString["t1"] == "ajaxLoad")
            {
                string virtualParentKey = Request.QueryString["virtualParentKey"];

                string para = string.Empty;                // "= 1";
                if (virtualParentKey == null)
                {
                    para = " is NULL";
                }
                else
                {
                    para = "=" + virtualParentKey;
                }

                string sql = @"SELECT p1.[ProductID] as ProductID, p1.[ProductName] as ProductName, p1.[ParentID] as ParentID, p3.childNodesCount as ChildNodesCount
FROM [Products] p1
LEFT OUTER JOIN 
(
	SELECT COUNT(*) AS childNodesCount , p2.[ParentID] AS pId 
	FROM [Products] p2
	GROUP BY p2.[ParentID]
) p3
ON p1.[ProductID] = p3.pId
WHERE p1.[ParentID] " + para;

                DataTable dt = OleDbHelper.ExecuteDataset(base.NorthWindConnectionString, CommandType.Text, sql).Tables[0];

                ASTreeViewNode root = new ASTreeViewNode("root");

                foreach (DataRow dr in dt.Rows)
                {
                    string productName     = dr["ProductName"].ToString();
                    string productId       = dr["ProductID"].ToString();
                    string parentId        = dr["ParentID"].ToString();
                    int    childNodesCount = 0;
                    if (!string.IsNullOrEmpty(dr["ChildNodesCount"].ToString()))
                    {
                        childNodesCount = int.Parse(dr["ChildNodesCount"].ToString());
                    }

                    ASTreeViewLinkNode node = new ASTreeViewLinkNode(productName, productId);
                    node.VirtualNodesCount = childNodesCount;
                    node.VirtualParentKey  = productId;
                    node.IsVirtualNode     = childNodesCount > 0;
                    node.NavigateUrl       = "#";
                    node.AdditionalAttributes.Add(new KeyValuePair <string, string>("onclick", "return false;"));

                    root.AppendChild(node);
                }



                HtmlGenericControl ulRoot = new HtmlGenericControl("ul");
                astvMyTree2.TreeViewHelper.ConvertTree(ulRoot, root, false);
                foreach (Control c in ulRoot.Controls)
                {
                    c.RenderControl(writer);
                }
            }
            else if (Request.QueryString["t2"] == "ajaxAdd")
            {
                string addNodeText     = Request.QueryString["addNodeText"];
                int    parentNodeValue = int.Parse(Request.QueryString["parentNodeValue"]);

                string maxSql = "select max( productId ) from products";
                int    max    = (int)OleDbHelper.ExecuteScalar(base.NorthWindConnectionString, CommandType.Text, maxSql);
                int    newId  = max + 1;

                string sql = string.Format(@"INSERT INTO products( productid, Discontinued, productname, parentid ) values( {0} ,0, '{1}', {2})"
                                           , max + 1, addNodeText.Replace("'", "''"), parentNodeValue);

                int i = OleDbHelper.ExecuteNonQuery(base.NorthWindConnectionString, CommandType.Text, sql);

                ASTreeViewNode root = new ASTreeViewNode("root");

                ASTreeViewLinkNode node = new ASTreeViewLinkNode(addNodeText, newId.ToString());
                node.NavigateUrl = "#";
                node.AdditionalAttributes.Add(new KeyValuePair <string, string>("onclick", "return false;"));

                root.AppendChild(node);

                HtmlGenericControl ulRoot = new HtmlGenericControl("ul");
                astvMyTree2.TreeViewHelper.ConvertTree(ulRoot, root, false);
                foreach (Control c in ulRoot.Controls)
                {
                    c.RenderControl(writer);
                }
            }
            else
            {
                base.Render(writer);
            }
        }
        protected override void Render(HtmlTextWriter writer)
        {
            if (Request.QueryString["t"] == "ajaxAdd")
            {
                string addNodeText     = HttpUtility.UrlDecode(Request.QueryString["addNodeText"]);
                int    parentNodeValue = int.Parse(HttpUtility.UrlDecode(Request.QueryString["parentNodeValue"]));

                string maxSql = "select max( productId ) from products";
                int    max    = (int)OleDbHelper.ExecuteScalar(base.NorthWindConnectionString, CommandType.Text, maxSql);
                int    newId  = max + 1;

                string sql = string.Format(@"INSERT INTO products( productid, Discontinued, productname, parentid ) values( {0} ,0, '{1}', {2})"
                                           , max + 1, addNodeText.Replace("'", "''"), parentNodeValue);

                int i = OleDbHelper.ExecuteNonQuery(base.NorthWindConnectionString, CommandType.Text, sql);

                ASTreeViewNode root = new ASTreeViewNode("root");

                ASTreeViewLinkNode node = new ASTreeViewLinkNode(addNodeText, newId.ToString());
                node.NavigateUrl = "#";
                node.AdditionalAttributes.Add(new KeyValuePair <string, string>("onclick", "return false;"));

                root.AppendChild(node);

                HtmlGenericControl ulRoot = new HtmlGenericControl("ul");
                astvMyTree.TreeViewHelper.ConvertTree(ulRoot, root, false);
                foreach (Control c in ulRoot.Controls)
                {
                    c.RenderControl(writer);
                }

                /*
                 * foreach( DataRow dr in dt.Rows )
                 * {
                 *      string productName = dr["ProductName"].ToString();
                 *      string productId = dr["ProductID"].ToString();
                 *      string parentId = dr["ParentID"].ToString();
                 *      int childNodesCount = 0;
                 *      if( !string.IsNullOrEmpty( dr["ChildNodesCount"].ToString() ) )
                 *              childNodesCount = int.Parse( dr["ChildNodesCount"].ToString() );
                 *
                 *      ASTreeViewLinkNode node = new ASTreeViewLinkNode( productName, productId );
                 *      node.VirtualNodesCount = childNodesCount;
                 *      node.VirtualParentKey = productId;
                 *      node.IsVirtualNode = childNodesCount > 0;
                 *      node.NavigateUrl = "#";
                 *      node.AdditionalAttributes.Add( new KeyValuePair<string, string>( "onclick", "return false;" ) );
                 *
                 *      root.AppendChild( node );
                 * }
                 *
                 *
                 *
                 * HtmlGenericControl ulRoot = new HtmlGenericControl( "ul" );
                 * astvMyTree.TreeViewHelper.ConvertTree( ulRoot, root, false );
                 * foreach( Control c in ulRoot.Controls )
                 *      c.RenderControl( writer );*/
            }
            else
            {
                base.Render(writer);
            }
        }
        protected override void Render(HtmlTextWriter writer)
        {
            if (this.Page.Request.QueryString["t1"] == "ajaxLoad")
            {
                #region ajaxLoad

                string virtualParentKey = this.Page.Request.QueryString["virtualParentKey"];

                string para = string.Empty;                // "= 1";
                if (virtualParentKey == null)
                {
                    para = " is NULL";
                }
                else
                {
                    para = "=" + virtualParentKey;
                }

                string sql = @"SELECT p1.[ProductID] as ProductID, p1.[ProductName] as ProductName, p1.[ParentID] as ParentID, p3.childNodesCount as ChildNodesCount
FROM [Products] p1
LEFT OUTER JOIN 
(
	SELECT COUNT(*) AS childNodesCount , p2.[ParentID] AS pId 
	FROM [Products] p2
	GROUP BY p2.[ParentID]
) p3
ON p1.[ProductID] = p3.pId
WHERE p1.[ParentID] " + para;

                DataTable dt = OleDbHelper.ExecuteDataset(this.NorthWindConnectionString, CommandType.Text, sql).Tables[0];

                ASTreeViewNode root = new ASTreeViewNode("root");

                foreach (DataRow dr in dt.Rows)
                {
                    string productName     = dr["ProductName"].ToString();
                    string productId       = dr["ProductID"].ToString();
                    string parentId        = dr["ParentID"].ToString();
                    int    childNodesCount = 0;
                    if (!string.IsNullOrEmpty(dr["ChildNodesCount"].ToString()))
                    {
                        childNodesCount = int.Parse(dr["ChildNodesCount"].ToString());
                    }

                    ASTreeViewLinkNode node = new ASTreeViewLinkNode(productName, productId);
                    node.VirtualNodesCount = childNodesCount;
                    node.VirtualParentKey  = productId;
                    node.IsVirtualNode     = childNodesCount > 0;
                    node.NavigateUrl       = "#";
                    node.AdditionalAttributes.Add(new KeyValuePair <string, string>("onclick", "return false;"));

                    root.AppendChild(node);
                }


                writer.Write(astvMyTree.AjaxResponseStartTag);

                HtmlGenericControl ulRoot = new HtmlGenericControl("ul");
                astvMyTree.TreeViewHelper.ConvertTree(ulRoot, root, false);
                foreach (Control c in ulRoot.Controls)
                {
                    c.RenderControl(writer);
                }


                writer.Write(astvMyTree.AjaxResponseEndTag);

                #endregion
            }
            else if (this.Page.Request.QueryString["t2"] == "ajaxAdd")
            {
                #region ajaxAdd

                string addNodeText     = this.Page.Request.QueryString["addNodeText"];
                int    parentNodeValue = int.Parse(this.Page.Request.QueryString["parentNodeValue"]);

                string maxSql = "select max( productId ) from products";
                int    max    = (int)OleDbHelper.ExecuteScalar(this.NorthWindConnectionString, CommandType.Text, maxSql);
                int    newId  = max + 1;

                string sql = string.Format(@"INSERT INTO products( productid, Discontinued, productname, parentid ) values( {0} ,0, '{1}', {2})"
                                           , max + 1, addNodeText.Replace("'", "''"), parentNodeValue);

                int i = OleDbHelper.ExecuteNonQuery(this.NorthWindConnectionString, CommandType.Text, sql);

                ASTreeViewNode root = new ASTreeViewNode("root");

                ASTreeViewLinkNode node = new ASTreeViewLinkNode(addNodeText, newId.ToString());
                node.NavigateUrl = "#";
                node.AdditionalAttributes.Add(new KeyValuePair <string, string>("onclick", "return false;"));

                root.AppendChild(node);


                writer.Write(astvMyTree.AjaxResponseStartTag);

                HtmlGenericControl ulRoot = new HtmlGenericControl("ul");
                astvMyTree.TreeViewHelper.ConvertTree(ulRoot, root, false);
                foreach (Control c in ulRoot.Controls)
                {
                    c.RenderControl(writer);
                }

                writer.Write(astvMyTree.AjaxResponseEndTag);

                #endregion
            }
            else
            {
                base.Render(writer);

                #region render click script

                string clickScript = string.Format(@"
<script type='text/javascript'>
function nodeSelectHandler{0}(elem){{
	document.getElementById('{1}').value = encodeURIComponent(elem.innerHTML);
	document.getElementById('{2}').value = elem.parentNode.getAttribute(""treeNodeValue"");
	document.getElementById('{3}').click();
}}
</script>"
                                                   , this.ClientID                     /*0*/
                                                   , this.hfSelectedNodeText.ClientID  /*1*/
                                                   , this.hfSelectedNodeValue.ClientID /*2*/
                                                   , this.btnPostBackTrigger.ClientID /*3*/);

                writer.Write(clickScript);

                #endregion
            }
        }
Example #28
0
        private void GenerateTree()
        {
            if (((PageBase)Page).NSurveyUser.Identity.UserId == -1 ||
                !(((PageBase)Page).NSurveyUser.HasRight(NSurveyRights.AccessSurveyList) || ((PageBase)Page).NSurveyUser.Identity.IsAdmin))
            {
                astvMyTree.Visible = false; return;
            }

            astvMyTree.Visible = true;
            FolderData folders;

            folders = new Folders().GetTreeNodes(((PageBase)Page).NSurveyUser.Identity.UserId);
            if (folders.TreeNodes.Count == 0)
            {
                return;
            }
            ASTreeViewDataTableColumnDescriptor descripter = new ASTreeViewDataTableColumnDescriptor("NodeName", "ItemId", "ParentFolderId");

            this.astvMyTree.DataTableRootNodeValue = null;
            this.astvMyTree.DataSourceDescriptor   = descripter;
            this.astvMyTree.DataSource             = folders.TreeNodes;
            this.astvMyTree.DataBind();
            string sfId = ((PageBase)Page).SelectedFolderId.HasValue ? "f" + ((PageBase)Page).SelectedFolderId.ToString() : "";

            System.Collections.Hashtable h = (System.Collections.Hashtable)Session["treeCtrl"];

            // set customized icons
            astvMyTree.EnableCustomizedNodeIcon = false;

            this.astvMyTree.TraverseTreeNode(this.astvMyTree.RootNode, delegate(ASTreeViewNode node)
            {
                node.Selected = false;
                if (node.NodeValue.StartsWith("f") && node.ParentNode == this.astvMyTree.RootNode)
                {
                    node.AdditionalAttributes.Add(
                        new KeyValuePair <string, string>(
                            "disableDelFolder"
                            , "true"));
                }
                if (node.ChildNodes.Count == 0 && node.NodeValue.StartsWith("f"))
                {
                    // add empty node to show folder icon and set to closed state
                    node.AppendChild(new ASTreeViewNode(""));
                    node.EnableOpenClose = false;
                    node.OpenState       = ASTreeViewNodeOpenState.Close;
                    if (h != null && h.Contains(node.NodeValue))
                    {
                        h.Remove(node.NodeValue);
                    }
                }
                else if (node.NodeValue.StartsWith("s"))
                {
                    node.AdditionalAttributes.Add(
                        new KeyValuePair <string, string>(
                            "disableAddFolder"
                            , "true"));
                    node.AdditionalAttributes.Add(
                        new KeyValuePair <string, string>(
                            "disableRenFolder"
                            , "true"));
                    //JJ If the Survey is current set it as selected node
                    if (((PageBase)Page).getSurveyId() == int.Parse(node.NodeValue.Substring(1)))
                    {
                        node.Selected = true;
                    }
                }

                string nv = string.IsNullOrEmpty(node.NodeValue) ? "" : node.NodeValue;

                //  node.EnableSelection = !string.IsNullOrEmpty(nv);

                //JJ Set Folder as selected only if there is no current survey.If there is current survey it is set as selected
                if (((PageBase)Page).getSurveyId() == -1)
                {
                    if (!string.IsNullOrEmpty(nv) && nv == sfId)
                    {
                        node.Selected = true;
                    }
                }

                if (h != null && h[node.NodeValue] != null)
                {
                    node.OpenState = (ASTreeViewNodeOpenState)h[node.NodeValue];
                }
                else
                {
                    node.OpenState = node.ParentNode == astvMyTree.RootNode ? ASTreeViewNodeOpenState.Open : ASTreeViewNodeOpenState.Close;
                }
            });

            if (string.IsNullOrEmpty(sfId))
            {
                this.astvMyTree.RootNode.ChildNodes[0].Selected = true;
            }

            ASTreeViewNode rootNode = this.astvMyTree.RootNode.ChildNodes[0];

            rootNode.EnableDragDrop = false;

            /// if root node is empty we hide it
            if (rootNode.ChildNodes.Count == 1 && string.IsNullOrEmpty(rootNode.ChildNodes[0].NodeValue))
            {
                // add empty node to show folder icon and set to closed state
                rootNode.EnableOpenClose = false;
                rootNode.OpenState       = ASTreeViewNodeOpenState.Close;
            }

            if (h == null)
            {
                StoreOpenCloseState();
            }
        }
        private void GenerateTreeByLevel( int nodesPerLevel )
        {
            if( nodesPerLevel > 50 )
            {

                this.divConsole.InnerHtml += ( string.Format( "{0} nodes, too many, isn't it? :-)", nodesPerLevel * nodesPerLevel ) );

                //FlashMessage.SetFlash( string.Format( "{0} nodes, too many, isn't it? :-)", nodesPerLevel * nodesPerLevel ), FlashMessage.FlashMessageType.Error );
                return;
            }

            for( int i = 0; i < nodesPerLevel; i++ )
            {
                ASTreeViewNode l1 = new ASTreeViewNode( string.Format( "Node-L{0}-{1}", 1, i ) );
                this.astvMyTree.RootNode.ChildNodes.Add( l1 );

                for( int j = 0; j < nodesPerLevel; j++ )
                {
                    ASTreeViewNode l2 = new ASTreeViewNode( string.Format( "Node-L{0}-{1}-{2}", 2, i, j ) );
                    l1.ChildNodes.Add( l2 );

                    /*
                    for( int k = 0; k < nodesPerLevel; k++ )
                    {
                        ASTreeViewNode l3 = new ASTreeViewNode( string.Format( "Node-{0}-{1}", 3, k ) );
                        l2.ChildNodes.Add( l3 );
                    }*/
                }
            }

            //FlashMessage.SetFlash( string.Format( "{0} nodes generated.", nodesPerLevel * nodesPerLevel ) );

            this.divConsole.InnerHtml += ( string.Format( ">>{0} nodes generated.<br />", nodesPerLevel * nodesPerLevel ) );
        }
		protected override void Render( HtmlTextWriter writer )
		{
			if( this.Page.Request.QueryString["t1"] == "ajaxLoad" )
			{
				#region ajaxLoad

				string virtualParentKey = this.Page.Request.QueryString["virtualParentKey"];

				string para = string.Empty;// "= 1";
				if( virtualParentKey == null )
					para = " is NULL";
				else
					para = "=" + virtualParentKey;

				string sql = @"SELECT p1.[ProductID] as ProductID, p1.[ProductName] as ProductName, p1.[ParentID] as ParentID, p3.childNodesCount as ChildNodesCount
FROM [Products] p1
LEFT OUTER JOIN 
(
	SELECT COUNT(*) AS childNodesCount , p2.[ParentID] AS pId 
	FROM [Products] p2
	GROUP BY p2.[ParentID]
) p3
ON p1.[ProductID] = p3.pId
WHERE p1.[ParentID] " + para;

				DataTable dt = OleDbHelper.ExecuteDataset( this.NorthWindConnectionString, CommandType.Text, sql ).Tables[0];

				ASTreeViewNode root = new ASTreeViewNode( "root" );

				foreach( DataRow dr in dt.Rows )
				{
					string productName = dr["ProductName"].ToString();
					string productId = dr["ProductID"].ToString();
					string parentId = dr["ParentID"].ToString();
					int childNodesCount = 0;
					if( !string.IsNullOrEmpty( dr["ChildNodesCount"].ToString() ) )
						childNodesCount = int.Parse( dr["ChildNodesCount"].ToString() );

					ASTreeViewLinkNode node = new ASTreeViewLinkNode( productName, productId );
					node.VirtualNodesCount = childNodesCount;
					node.VirtualParentKey = productId;
					node.IsVirtualNode = childNodesCount > 0;
					node.NavigateUrl = "#";
					node.AdditionalAttributes.Add( new KeyValuePair<string, string>( "onclick", "return false;" ) );

					root.AppendChild( node );
				}


				writer.Write( astvMyTree.AjaxResponseStartTag );

				HtmlGenericControl ulRoot = new HtmlGenericControl( "ul" );
				astvMyTree.TreeViewHelper.ConvertTree( ulRoot, root, false );
				foreach( Control c in ulRoot.Controls )
					c.RenderControl( writer );


				writer.Write( astvMyTree.AjaxResponseEndTag );

				#endregion

			}
			else if( this.Page.Request.QueryString["t2"] == "ajaxAdd" )
			{
				#region ajaxAdd

				string addNodeText = this.Page.Request.QueryString["addNodeText"];
				int parentNodeValue = int.Parse( this.Page.Request.QueryString["parentNodeValue"] );

				string maxSql = "select max( productId ) from products";
				int max = (int)OleDbHelper.ExecuteScalar( this.NorthWindConnectionString, CommandType.Text, maxSql );
				int newId = max + 1;

				string sql = string.Format( @"INSERT INTO products( productid, Discontinued, productname, parentid ) values( {0} ,0, '{1}', {2})"
					, max + 1, addNodeText.Replace( "'", "''" ), parentNodeValue );

				int i = OleDbHelper.ExecuteNonQuery( this.NorthWindConnectionString, CommandType.Text, sql );

				ASTreeViewNode root = new ASTreeViewNode( "root" );

				ASTreeViewLinkNode node = new ASTreeViewLinkNode( addNodeText, newId.ToString() );
				node.NavigateUrl = "#";
				node.AdditionalAttributes.Add( new KeyValuePair<string, string>( "onclick", "return false;" ) );

				root.AppendChild( node );


				writer.Write( astvMyTree.AjaxResponseStartTag );

				HtmlGenericControl ulRoot = new HtmlGenericControl( "ul" );
				astvMyTree.TreeViewHelper.ConvertTree( ulRoot, root, false );
				foreach( Control c in ulRoot.Controls )
					c.RenderControl( writer );

				writer.Write( astvMyTree.AjaxResponseEndTag );

				#endregion
			}
			else
			{
				base.Render( writer );

				#region render click script

				string clickScript = string.Format( @"
<script type='text/javascript'>
function nodeSelectHandler{0}(elem){{
	document.getElementById('{1}').value = encodeURIComponent(elem.innerHTML);
	document.getElementById('{2}').value = elem.parentNode.getAttribute(""treeNodeValue"");
	document.getElementById('{3}').click();
}}
</script>"
					, this.ClientID /*0*/
					, this.hfSelectedNodeText.ClientID /*1*/
					, this.hfSelectedNodeValue.ClientID /*2*/
					, this.btnPostBackTrigger.ClientID /*3*/);

				writer.Write( clickScript );

				#endregion
			}

		}
        /// <summary>
        /// compare to the OriginalTreeNodes to find the nodes which have been changed
        /// </summary>
        private void ResolveTreeNodesModification()
        {
            //the result string
            StringBuilder sb = new StringBuilder();

            #region traverse all the nodes, detect new nodes, modified nodes
            //traverse all the nodes, detect new nodes, modified nodes
            ASTreeView.ASTreeNodeHandlerDelegate nodeDelegate = delegate(ASTreeViewNode node)
            {
                //skip RootNode
                if (node.Equals(this.astvMyTree.RootNode))
                {
                    return;
                }

                object obj = this.OriginalTreeNodes[node.NodeValue];
                //if node is a new node, it can't be found in the OriginalNodes
                if (obj == null)
                {
                    sb.Append(string.Format("[NEW] Node: {0} <br />", node.NodeText));
                }
                else
                {
                    ASTreeViewNode originalNode = (ASTreeViewNode)obj;

                    //if the node has been changed
                    //compare, here I just demo NodeText and ParentNodeId
                    if (node.NodeText != originalNode.NodeText)
                    {
                        sb.Append(string.Format("[TEXT CHANGED]NodeText changed! Original Text:{0}, New Text: {1} <br />", originalNode.NodeText, node.NodeText));
                    }

                    if (node.ParentNode.NodeValue != originalNode.ParentNode.NodeValue)
                    {
                        sb.Append(string.Format("[PARENT CHANGED]Node's parent changed! Original Parent: {0}, New Parent: {1} <br />", originalNode.ParentNode.NodeText, node.ParentNode.NodeText));
                    }

                    int oldPos = originalNode.ParentNode.IndexOf(originalNode);
                    int newPos = node.ParentNode.ChildNodes.IndexOf(node);
                    if (newPos != oldPos)
                    {
                        sb.Append(string.Format("[POSITION CHANGED]Node's position changed! Original Position: {0}, New Position: {1} <br />", oldPos, newPos));
                    }
                }
            };

            //do traverse
            astvMyTree.TraverseTreeNode(this.astvMyTree.RootNode, nodeDelegate);

            #endregion

            #region find deleted nodes

            //find deleted nodes
            List <string> originalNodesKeys = new List <string>();
            foreach (string key in this.OriginalTreeNodes.Keys)
            {
                originalNodesKeys.Add(key);
            }

            //traverse all the nodes, detect new nodes, modified nodes
            ASTreeView.ASTreeNodeHandlerDelegate nodeDeleteDelegate = delegate(ASTreeViewNode node)
            {
                //skip RootNode
                if (node.Equals(this.astvMyTree.RootNode))
                {
                    return;
                }

                if (originalNodesKeys.Contains(node.NodeValue))
                {
                    originalNodesKeys.Remove(node.NodeValue);
                }
            };

            //do traverse
            astvMyTree.TraverseTreeNode(this.astvMyTree.RootNode, nodeDeleteDelegate);

            //keys remain in the originalNodesKeys are the deleted nodes
            foreach (string deletedNodeKey in originalNodesKeys)
            {
                sb.Append(string.Format("[NODE DELETED]Original Node: {0}<br />", deletedNodeKey));
            }

            #endregion



            this.divConsole.InnerHtml += (string.Format(">>The following nodes have been changed: <div style='padding-left:20px;'>{0}</div>", sb.ToString()));
        }