如题!ASP.NET+C#

解决方案 »

  1.   

    也许对你有用客户端操作TreeView一直是比较头疼的问题,但也比较实用。好好研究了一下TreeView.htc,找到以下方法,不要告诉我你早已知道而懒得说:)1.设置所选节点,如选中第二个节点
    function SetSelNode()
    {
    TreeView1.selectedNodeIndex="1";
    }2.得到所选节点的Text,ID或NodeData
    function GetAttribute()
    {
    alert(TreeView1.getTreeNode(TreeView1.selectedNodeIndex).getAttribute("Text"));
    }
    替换Text为ID或NodeData,可分别得到所选节点的ID或NodeData3.修改节点属性,如修改第一个节点的Text
    function ModifyNode()
    {
    var node=TreeView1.getTreeNode("0");
    node.setAttribute("Text","hgknight");
    }4.得到点击节点
    function TreeView1.onclick()
    {
    alert(TreeView1.getTreeNode(TreeView1.clickedNodeIndex).getAttribute("Text"));
    }5.添加节点
    function AddNode()
    {
    var node=TreeView1.createTreeNode();
    node.setAttribute("Text","hgknight");
    TreeView1.add(node);
    }
      

  2.   

    下面的js 实现右键菜单弹出
    treeview.js
    var menuskin = "skin";
    var node = null;
    //Calculate string length, one chinese char impropriate two byte.
    String.prototype.lenB = function()
    {
    return this.replace(/[^\x00-\xff]/g,"**").length;
    }
    function hideMenu() 
    {
    popupMenu.style.visibility = "hidden";
    }

    function highlighItem() 
    {
    if (event.srcElement.className == "menuitems") 
    {
    event.srcElement.style.backgroundColor = "highlight";
    event.srcElement.style.color = "white";
    }
    } function lowlightItem() 
    {
    if (event.srcElement.className == "menuitems") 
    {
    event.srcElement.style.backgroundColor = "";
    event.srcElement.style.color = "black";
    window.status = "";
    }
    } //Call pop menu function
    function clickItem() 
    {    
    if (event.srcElement.className == "menuitems") 
    {
    if(event.srcElement.getAttribute("func") == "add" && node != null)
    {
    var strNewNodeName;
    strNewNodeName = prompt('请输入新的目录名字:','');
    if(strNewNodeName.lenB() < 20 & strNewNodeName.lenB() > 0) {
    window.document.getElementById("TBNewCatalogName").value = strNewNodeName;
    document.all.Button1.click();
    }
    else
    alert("目录名长度不对");
    }
    else if (event.srcElement.getAttribute("func") == "delete" && node != null)
    {
    if(confirm("确定要删除此目录吗?")) 
    {
    if(window.document.getElementById("TBNodeIndex").value == "0")
    alert("不能删除此目录.");
    else
    document.all.Button2.click();
    }
    }
    else if (event.srcElement.getAttribute("func") == "modify" && node != null)
    {
    //User can't edit root node name
    if(window.document.getElementById("TBNodeIndex").value != "0")
    {
    var strEditNodeName;
    strEditNodeName = prompt('请输入新的目录名字:','');
    if(strEditNodeName.lenB() < 20 & strEditNodeName.lenB() > 0) {
    window.document.getElementById("TBNewCatalogName").value = strEditNodeName;
    document.all.Button3.click();
    }
    else
    alert("目录名长度不对");
    }
    else
    alert("不能修改根结点");
    }
    }
    }
      
       
    function TreeView1.oncontextmenu()
    {
    var nodeindex = event.treeNodeIndex;
    if (typeof(nodeindex) == "undefined")
    {
    node = null;
    return;
    }
        
    node = TreeView1.getTreeNode(nodeindex);
    window.document.getElementById("TBNodeIndex").value = nodeindex;
        

    var rightedge = document.body.clientWidth-event.clientX;
    var bottomedge = document.body.clientHeight-event.clientY;
    if (rightedge <popupMenu.offsetWidth)
    {
    //old author code
    //popupMenu.style.left = document.body.scrollLeft + event.clientX - popupMenu.offsetWidth;
    popupMenu.style.left = 30;
    }
    else
    {
    //old author code
    //popupMenu.style.left = document.body.scrollLeft + event.clientX;
    popupMenu.style.left = 30;
    }
    if (bottomedge <popupMenu.offsetHeight)
    {
    popupMenu.style.top = document.body.scrollTop + event.clientY - popupMenu.offsetHeight;
    }
    else
    {
    popupMenu.style.top = document.body.scrollTop + event.clientY;
    }
    popupMenu.style.visibility = "visible";
    return false;

       
      

  3.   

    一个介绍很详细的treeview 客户端操作介绍.
    http://www.codeproject.com/aspnet/ClientSideTreeView.asp
      

  4.   

    回复人: bleempan(恒星-痕星) ( ) 信誉:99  2005-08-29 21:10:00  得分: 0  
     
     
       一个介绍很详细的treeview 客户端操作介绍.
    http://www.codeproject.com/aspnet/ClientSideTreeView.asp
      
     
    --------------------------
    建议楼主参考这个
      

  5.   

    谢谢各位大哥大姐(我想应该我还算小吧)哈哈。
    我参照了这个:
    http://www.66study.com/Article/web/net/framework/200506/47571.html
    下面的我就无法去实现和数据库联系起来,并且可以实现添加,修改,删除操作了!
    欢迎高手进来帮忙啊