<%@ Page Language="C#" AutoEventWireup="true" Inherits="ViewProductTypeSelected" Codebehind="ViewProductTypeSelected.aspx.cs" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>请选择您所要的产品类别</title>
    <script type ="text/javascript" src="ClientControls/common.js"></script>
    <link href="clientcontrols/commonstyle.css" type="text/css" rel="stylesheet"/>
    <base target="_self"/>
    <% Response.Expires = -1 ;%>
</head>
<body style="background-image: url(ClientControls/img/back3.gif); overflow:hidden;">
    <form id="form1" runat="server">
        <div class="tbtitleStyle" style=" padding-top:8px;">
            请选择您所要的产品类别
        </div>
        <div style ="overflow:hidden; height:100%; width :100%;text-align:left ;" class="titleBgStyle">
        <asp:TreeView ID="tvwProductType" CssClass="MicroTree" runat="server"  Height ="510px" Width="505px" ExpandDepth="10" ShowLines="True" AutoGenerateDataBindings="False" ShowCheckBoxes="All">
          </asp:TreeView>  
     </div>
        <div style ="display:none; ">
            <input id="hid_test" type="hidden" name="hid_test" runat="server"/>   
        </div>
    </form>    
   <script type="text/javascript">
        function window.onload()
        {
           
        }
        
        function CheckEvent()
        {
            try
            {
                var ReturnValue = "";
                var objNode = event.srcElement;
                var objID = objNode.getAttribute("ID");
                var NodeText = objNode.innerText;            
                var objchild = objNode.children;
                var count = objchild.length;
                if (objID != "tvwProductType" && objNode.tagName != "IMG" && objID.tagName != "IMG")
                {
                    if( NodeText != null && NodeText != "")
                    {
                        ReturnValue = NodeText;                     
                    }               
                } 
                
                if( objNode.tagName!= "INPUT" && objNode != "checkbox" &&
                objID != "tvwProductType" && objNode.tagName != "IMG" && objID.tagName != "IMG")
                {
                    var ID   =   window.event.srcElement.href.split(",")[1];   
                    ID  =   ID.substr(2,ID.length-4);   
                    
                    if(ID.indexOf("\\\\")   !=   -1)   
                    {   
                        ID   =   ID.split("\\\\");   
                        ID   =   ID[ID.length-1];   
                    }   
                      
                    var ID = escape(ID);
                    ReturnValue = ReturnValue + ";" + ID;
                    if( ReturnValue == null || ID == "0")
                    {
                        ReturnValue = "";
                    }
                    else
                    {
                        window.parent.returnValue = ReturnValue;
                        window.event.returnValue=false ;
                        window.close();
                    }
                 } 
                 
                if(objNode.tagName=="INPUT" && objNode.type == "checkbox")
                {
                    ReturnValue = window.event.srcElement.nextSibling.innerText;  
                        
                    var ID   =   window.event.srcElement.nextSibling.href.split(",")[1];   
                    ID  =   ID.substr(2,ID.length-4);   
                    
                    if(ID.indexOf("\\\\")   !=   -1)   
                    {   
                        ID   =   ID.split("\\\\");   
                        ID   =   ID[ID.length-1];   
                    }   
                      
                    var ID = escape(ID);
                    ReturnValue = ReturnValue + ";" + ID;
                    if( ReturnValue == null || ID == "0")
                    {
                        ReturnValue = "";
                    }
                    else if( ReturnValue.indexOf("*") != -1 )
                    {
                        ReturnValue = "";
                    }                    ReturnValue = ReturnValue + ",";
                                
                    window.parent.returnValue = ReturnValue;//alert(ReturnValue);
                    window.event.returnValue = false;
                    window.close(); 
                }  
            }
            catch(err)
            {
            }            
        }
        
        function btnSelect()
        {
            window.close();
        }
   </script>
</body>
</html>这是我的页面代码..我想让他实现treeview的多选.这个是一个公司的产品类别树.从数据库读取的节点,原先是单选的一切正常.现在是根本没法多选而且没法实现复选框的状态.点了也不会打勾新人小白求帮助了

解决方案 »

  1.   

    先到cnblog上搜下,然后再上Google上搜一下一般你就会遇到具体的问题了。
      

  2.   

    treeview  就有checkbox
    ShowCheckBoxes="All" http://topic.csdn.net/u/20100306/19/66863968-95da-4adf-b071-71a3a49e8627.html
      

  3.   

    <script type="text/javascript">
            //节点复选框操作
            function OnTreeNodeChecked() {
                var element = element = window.event.srcElement;            if (!IsCheckBox(element))
                    return;            var isChecked = element.checked;
                var tree = TV2_GetTreeById('<%=tv.ClientID %>');//树控件ID
                var node = TV2_GetNode(tree, element);            TV2_SetChildNodesCheckStatus(node, isChecked);            var parent = TV2_GetParentNode(tree, node);            TV2_NodeOnChildNodeCheckedChanged(tree, parent, isChecked);
            }  
        </script>
      

  4.   

    已经想出方法了..本来只要checkbox是支持多选的.只是因为写入了函数所以不支持多选了.我决定要重新改一下整个函数.好像工作量也不是很大.谢谢楼上的各位了