1、我用TreeView做权限设置
  根据管理员选择借点来生成权限字符串,但是我选择节点的Checkbox后遍历时却发现仍然为false
  说是没有回发,就照着网上说的用JS来PostBack,但是这样虽然触发了TreeNodeCheckChanged,这样每点击一个节点均会触 发这个事件,生成的字符串又是不对的
  求高手支招,有没有别的简易的方法来满足这样的需求呢
2、有时候网页关闭了,他马上弹出一个正在连接的空白网页,这样的话在运行就会弹出无法启动程序"http:/localhost:2844/xxxx",是什么原因呢,怎样彻底的关闭,就像Process.GetCurrentProcess().Kill();

解决方案 »

  1.   

    1、就是勾上节点的Checkbox后,遍历的时候检测他的Check属性仍然为false
      怎样解决 或者有么有别的好的方法实现权限设置2、就是弹出空白网页的原因(一直在连接),怎样彻底的关闭网页,不出现弹空页的现象
      

  2.   

    纯js可以么,试试看,不用TreeNodeCheckChanged
      

  3.   

    我最近做了一个有关权限的,是这样做的,将treeview放在一个web用户控件里面,将所有的节点都添加进去,在用到treeview的页面里引用treeview,在treeview页面的page_lode函数中进行权限的判断,根据不同权限删除不显示的节点。(我的用户权限是在数据库表中存在的)
      

  4.   

    谢谢,你是说弄一个JS的TreeView
    JS没怎么弄过啊,导入这个JS文件后,怎么把它显示在界面上呢?
    感觉Web的TreeView真不好用啊
      

  5.   

    第一个问题: 这样做,点击checkbox的时候不处理。点提交的时候,进行取值。name 如果一致的 Request.Form[name]就是你需要的了。第二个问题: 你详细描述下
      

  6.   

    我已开始就是不处理的(不回发),点击之后遍历所有的树节点发现尽管我勾了某个树节点他的CheckBox还是false,点提交的时候,进行取值,我已开始就是这样做的,在button事件里调用了了调用生成PermissionString的方法,调试到GetPermissionString方法里面即使勾了CheckBox他还是false public void GetPermissionString(ref string permission)
            {            int position, i;            List<TreeNode> functionTreeNodes = _FunctionTree.GetTreeNodes();            for (i = 0; i < functionTreeNodes.Count; i++)
                {
                    permission += "0FF";//默认无权限
                }            foreach (TreeNode item in functionTreeNodes)
                {
                    FunctionTreeNodeInfo info = (FunctionTreeNodeInfo)_FunctionTree.GetAppTreeNode(item).Info;                if (info.FuncNO == 0)
                    {
                        continue;
                    }                position = info.FuncNO - 1;
                    if (position < 0) continue;                position *= 3;                if (item.Checked)
                    {
                        //指定位置由0FF替换为1FF
                        Regex r = new Regex("0FF");
                        permission = r.Replace(permission, "1FF", 1, position);
                    }
                }        }        private bool GetInput()
            {
                try
                {
                    _Data.PermI_Name = txtName.Text;                _Data.PermI_PermissionString = permission;                _Data.PermI_Re = txtRe.Text;
                }
                catch (Exception ex)
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), null, "alert('" + ex.Message + "');", true);
                    return false;
                }            return true;
            }      
            protected void btnUpdate_Click(object sender, EventArgs e)
            {
                try
                {
                    MethodResult result;                if (!VerifyInput() || !GetInput()) return;                _Data.PermI_ID = _DataMg.DataList[index].EXS_PermissionInfo.PermI_ID;                result = _DataMg.UpdateData(_Data);                if (!result.Result)
                    {
                        ScriptManager.RegisterStartupScript(this, this.GetType(), null, "alert('" + result.FullMsg + "');", true);
                        return;
                    }                System.Web.UI.ScriptManager.RegisterStartupScript(this, this.GetType(), null, "alert('修改成功!');", true);                result = this._DataMg.LoadData();
                    if (!result.Result)
                    {
                        ScriptManager.RegisterStartupScript(this, this.GetType(), null, "alert('" + result.FullMsg + "');", true);
                    }
                }
                catch (Exception ex)
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), null, "alert('" + ex.Message + "');", true);
                }
            }第2问  好像我查出一些问题了,就是抛了异常之类的