⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 categoriestree.aspx.cs

📁 ASP.NET多线程编程(二),ASP.NET多线程编程(二) .
💻 CS
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Zeroone.FileSystem;
using Zeroone.Security.Permissions;
using Zeroone;
using Zeroone.Security;

public partial class Admin_CategoriesTree : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            TreeNode rooNode = new TreeNode();
            rooNode.Text = "ZerooneV3";
            rooNode.NavigateUrl = "#";
            rooNode.Target = "_self";

            Category c = CategoryController.GetCategory("/");
            TreeNode siteNode = new TreeNode();
            siteNode.NavigateUrl = "ManageCategories.aspx";
            siteNode.PopulateOnDemand = c.HasChild;
            siteNode.Text = c.Name;
            siteNode.Value = "/";

            TreeNode recycleNode = new TreeNode();
            recycleNode.Text = "回收站";
            recycleNode.NavigateUrl = "Recycles.aspx";
            recycleNode.ImageUrl = Globals.ApplicationPath + "/admin/resource/images/recycle.gif";

            rooNode.ChildNodes.Add(siteNode);
            //只有管理才能管理回收站
            if(User.IsInRole(RoleController.Administrators))
                rooNode.ChildNodes.Add(recycleNode);

            //添加到控件树
            this.tvCategories.Nodes.Add(rooNode);
        }

    }

    //添加子节点
    private TreeNode AddChild(TreeNode treeNode, string parentPath)
    {
        //子栏目
        CategoryCollection categories = CategoryController.GetChildCategories(parentPath);
        if (categories.Count > 0)
        {
            foreach (Category c in categories)
            {
                if (!CategoryController.IsBuiltInSystemPath(c.Path))
                {
                    TreeNode childTreeNode = new TreeNode();
                    childTreeNode.PopulateOnDemand = c.HasChild;
                    childTreeNode.Value = c.Path;
                    if (c.IsAuthorization(PermissionController.ManageDocuments))
                    {
                        childTreeNode.NavigateUrl = c.Path.Substring(1) + "ManageCategories.aspx";
                        childTreeNode.Text = c.Name;
                        childTreeNode.ImageUrl = Globals.ApplicationPath + "/admin/resource/images/childCategory.gif";
                    }
                    else
                    {
                        childTreeNode.NavigateUrl = "#";
                        childTreeNode.Target = "_self";
                        childTreeNode.Text = "<font color=\"#666666\">" + c.Name + "</font>";
                        childTreeNode.ImageUrl = Globals.ApplicationPath + "/admin/resource/images/jinyongchildCategory.gif";
                    }

                    //添加到父节点
                    treeNode.ChildNodes.Add(childTreeNode);
                }
            }
        }

        return treeNode;
    }
    protected void tvCategories_TreeNodePopulate(object sender, TreeNodeEventArgs e)
    {
        e.Node.ChildNodes.Clear();
        //添加子节点
        this.AddChild(e.Node, e.Node.Value);
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -