treeview级联修改状态

JS

 function PostBackByObject()
       {
          var o=window.event.srcElement;
          if(o.tagName=="INPUT"&& o.type=="checkbox")
          {
             __doPostBack("",""); //回发服务器
          }
       }

cs文件

 protected void Page_Load(object sender, EventArgs e)
    {

              tv_rights.Attributes.Add("onclick", "PostBackByObject()");

    }

 

    private void SetChildChecked(TreeNode Parent)
    {
        foreach (TreeNode tn in Parent.ChildNodes)
        {
            tn.Checked = Parent.Checked;
            if (tn.ChildNodes.Count > 0)
            {
                SetChildChecked(tn);
            }
        }

    }

    protected void tv_rights_TreeNodeCheckChanged(object sender, TreeNodeEventArgs e)
    {
        SetChildChecked(e.Node);
    }

 

你可能感兴趣的:(treeview级联修改状态)