首页新闻找找看学习计划

在aspx代码和aspx.cs代码中如何给每个父元素对应的子元素加一个共同的标号,并把子元素共同的标号和子元素Id绑定在一起,并一起传递到TeamMap.aspx界面中处理,这里的参数如何传递?

0
悬赏园豆:40 [已解决问题] 解决于 2017-09-08 14:48
  1 using BPMS.Business;
  2 using BPMS.Entity;
  3 using BPMS.IBusiness;
  4 using DotNet.Utilities;
  5 using System;
  6 using System.Collections;
  7 using System.Collections.Generic;
  8 using System.Linq;
  9 using System.Text;
 10 using System.Web;
 11 using System.Web.UI;
 12 using System.Web.UI.WebControls;
 13 
 14 namespace BPMS.WEB.VoIplatform.Team
 15 {
 16     public partial class TeamTree : System.Web.UI.Page
 17     {
 18         public StringBuilder strHtml = new StringBuilder();
 19         Info_Veh_TeamIBLL info_veh_teamibll = new Info_Veh_TeamBLL();
 20         Info_Team_MemberIBLL info_team_memberibll = new Info_Team_MemberBLL();
 21         protected void Page_Load(object sender, EventArgs e)
 22         {
 23             if (!IsPostBack)
 24             {
 25                 GetTree();
 26             }
 27         }
 28         /// <summary>
 29         /// 组织机构
 30         /// </summary>
 31         public void GetTree()
 32         {
 33             IList list = info_veh_teamibll.GetList();
 34             strHtml.Append("<li>");
 35             strHtml.Append("<div><img src='/Themes/images/16/house.png' style='vertical-align: middle;' alt=''/><span>车队列表</span></div>");
 36             //创建子节点
 37             strHtml.Append(GetTreeNode(list));
 38             strHtml.Append("</li>");
 39         }
 40         /// <summary>
 41         /// 创建子节点
 42         /// </summary>
 43         /// <param name="list">list</param>
 44         /// <returns></returns>
 45         public string GetTreeNode(IList list)
 46         {
 47             Info_Veh_Team info_veh_team = new Info_Veh_Team();
 48             StringBuilder sb_TreeNode = new StringBuilder();
 49             List<Info_Veh_Team> itemNode = IListHelper.IListToList<Info_Veh_Team>(list);   
 50             
 51             //IList nextlist = info_team_memberibll.GetList();
 52             int index1 = 0;
 53             string strclass = "";
 54             if (itemNode.Count > 0)
 55             {
 56                 sb_TreeNode.Append("<ul>");
 57                 foreach (Info_Veh_Team entity in itemNode)
 58                 {
 59                     if (index1 == 0)
 60                         strclass = "collapsableselected";
 61                     else
 62                         strclass = "";
 63                     sb_TreeNode.Append("<li>");
 64                     sb_TreeNode.Append("<div class='" + strclass + "'><input id='" + entity.team_id + "' type='checkbox'  /><span>" + entity.team_name + "</span></div>");
 65                     
 66                     info_veh_team = info_veh_teamibll.GetEntity(entity.team_id);
 67                     StringBuilder where = new StringBuilder();
 68                     //where.Append(" and team_id");            //我可以在此处增添一个判别条件,判断一个team_id对应只显示他的车辆列表
 69                     //where.Append("=");
 70                     //where.Append("'" + info_veh_team.team_id + "'");
 71                     where.Append("and team_id='" + info_veh_team.team_id + "'");      
 72                     IList nextlist = info_team_memberibll.GetListWhere(where, null);
 73                     //IList nextlist = info_team_memberibll.GetList();
 74                     sb_TreeNode.Append(GetTreeNodeNext(nextlist, entity.team_id, index1));
 75                     sb_TreeNode.Append("</li>");
 76                     index1++;
 77                 }
 78                 sb_TreeNode.Append("</ul>");
 79             }
 80             return sb_TreeNode.ToString();
 81         }
 82         /// <summary>
 83         /// 创建子节点
 84         /// </summary>
 85         /// <param name="list">list</param>
 86         /// <returns></returns>
 87         public string GetTreeNodeNext(IList list, String team_id, int index1)
 88         {
 89             StringBuilder sb_TreeNode = new StringBuilder();
 90             List<Info_Team_Member> itemNode = IListHelper.IListToList<Info_Team_Member>(list);
 91             int index2 = 0;
 92             string strclass = "";
 93             if (itemNode.Count > 0)
 94             {
 95                 sb_TreeNode.Append("<ul>");
 96                 foreach (Info_Team_Member entity in itemNode)
 97                 {
 98                     if (index2 == 0)
 99                         strclass = "collapsableselected";
100                     else
101                         strclass = "";
102                     sb_TreeNode.Append("<li>");
103                     sb_TreeNode.Append("<div class='" + strclass + "'><input id='" + entity.member_id + "' type='checkbox'  name='" + team_id + "' index='" + index1 + "' /><span>" + entity.veh_lpn + "</span></div>");
104                     sb_TreeNode.Append("</li>");
105                     index2++;
106                 }
107                 sb_TreeNode.Append("</ul>");
108             }
109             return sb_TreeNode.ToString();
110         }
111 
112     }
113 }
  1 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TeamTree.aspx.cs" Inherits="BPMS.WEB.VoIplatform.Team.TeamTree" %>
  2 
  3 <!DOCTYPE html>
  4 
  5 <html xmlns="http://www.w3.org/1999/xhtml">
  6 <head id="Head1" runat="server">
  7     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  8 
  9     <title>车队列表</title>
 10     <link href="/Themes/Styles/style.css" rel="stylesheet" />
 11     <script src="/Themes/Scripts/jquery-1.8.2.min.js"></script>
 12     <script src="/Themes/Scripts/TreeView/jquery.cookie.js"></script>
 13     <link href="/Themes/Scripts/TreeView/jquery.treeview.css" rel="stylesheet" />
 14     <script src="/Themes/Scripts/TreeView/jquery.treeview.js"></script>
 15     <script src="/Themes/Scripts/FunctionJS.js"></script>
 16     <script>
 17         $(function () {
 18             divresize('.div-body', 30);
 19             treeAttrCss();
 20             GetClickValue();
 21         })
 22         //初始化
 23         //var teamIds = [];
 24         var indexs = [];
 25         var vehIds = [];
 26         function GetClickValue() {
 27             //vehId = $('.collapsableselected').attr('id');
 28             
 29             var path = 'TeamMap.aspx';      
 30             window.parent.frames["target_right"].location = path;
 31             Loading(true);
 32 
 33             //$(".strTree li div").click(function () {
 34             //    vehId = $(this).attr('id');
 35             //    FullName = $(this).find('span').html();
 36             //    var path = 'VehMap.aspx?vehid=' + vehId;
 37             //    window.parent.frames["target_right"].location = path;
 38             //    Loading(true);
 39             //});
 40 
 41             $('.strTree li div input:checkbox').click(function () {//问题:如何实现选中车队,对应成员全部选中,并传对应所有成员的member_id,而不是传team_id
 42                 $(".strTree li div input:checkbox:checked").each(function (i) {  //由于复选框选中多个,所以循环输出
 43                     team_id = document.getElementsByName($(this).attr('id'));    //通过name   获取name='team_id'的子元素        ($(this).attr('id'))为被选中的车队名               
 44                     team = document.getElementById($(this).attr('id')); //通过id获取   获取的是被勾选的车队或者车辆的id
 45 
 46                     alert($(this).attr('id'));
 47                     if (team.checked) {
 48                         //alert(n);
 49                         for (i = 0; i < team_id.length; i++) {
 50                             team_id[i].checked = true;
 51                         }
 52                     } else {
 53                         for (i = 0; i < team_id.length; i++) {
 54                             team_id[i].checked = false;
 55                         }
 56                     }
 57                     alert(team_id.length);
 58                     //var Ids = [];          
 59                     var vehIds = [];
 60                     indexs[i] = i + 1;
 61                     $(".strTree li div input:checkbox:checked").each(function (j) {  //由于复选框选中多个,所以循环输出
 62                         v = document.getElementsByName($(this).attr('id'));
 63                         //alert("v的值" + v.length);
 64                         if (v.length == 0) {
 65                             vehIds[j - 1] = $(this).attr('id');
 66                         }
 67                         //vehIds[i] = $(this).attr('id');   //attr() 方法设置或返回被选元素的属性值            
 68                         alert(vehIds);
 69                     });
 70                     alert("veh的个数" + vehIds.length);
 71                     self.vehIds = vehIds;
 72 
 73                     //console.debug(teamIds);
 74                     var path = 'TeamMap.aspx';
 75                     window.parent.frames['target_right'].location = path;
 76                     Loading(true);
 77                 });
 78                
 79 
 80                 //alert(team_id.length);
 81                 /*team_id2 = document.getElementsByName($(this).attr('id'));    //通过name   获取name='team_id'的子元素        ($(this).attr('id'))为被选中的车队名               
 82                 team2 = document.getElementById($(this).attr('id')); //通过id获取   获取的是被勾选的车队或者车辆的id      
 83                 if (team2.checked) {
 84                     team_id2.checked = true;
 85                 } else {
 86                     team_id2.checked = false;
 87                 } */         
 88                                              
 89                 
 90                 //vehIds.splice(0,1);
 91                 //alert("veh的个数" + vehIds.length);      
 92                 
 93             });
 94         }
 95     </script>
 96 </head>
 97 <body>
 98     <form id="form1" runat="server">
 99         <div class="btnbartitle">
100             <div>
101                 车队列表
102             </div>
103         </div>
104         <div class="line"></div>
105         <div class="div-body">
106             <ul class="black strTree">
107                 <%=strHtml %>
108             </ul>
109         </div>
110     </form>
111 </body>
112 </html>

在aspx代码和aspx.cs代码中如何给每个父元素对应的子元素加一个共同的标号,并把子元素共同的标号和子元素Id绑定在一起,并一起传递到TeamMap.aspx界面中处理,这里的参数如何传递?

张熙12的主页 张熙12 | 初学一级 | 园豆:80
提问于:2017-07-28 11:29
< >
分享
最佳答案
1

共同的标号,直接给子元素一个自定义属性就可以,你传值的时候必定要触发某些事件,那这时再获取之前定义的自定义属性,与子元素的id一起传不就行了。传参数可以用id=5&n=5,n表示共同的标号

收获园豆:40
龙行天涯 | 小虾三级 |园豆:1832 | 2017-07-28 13:52
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册