Infragistics web tree的应用(例子一)

CS 部分

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using Infragistics.WebUI.UltraWebNavigator;
namespace webtree1
{
 /// <summary>
 /// Summary description for WebForm1.
 /// </summary>
 public class WebForm1 : System.Web.UI.Page
 {
  protected Infragistics.WebUI.UltraWebNavigator.UltraWebTree UltraWebTree1;
  private DataTable dt_tree;
  private DataView dv;

  private void Page_Load(object sender, System.EventArgs e)
  {
   if(!this.IsPostBack)
   {
    UltraWebTree1.CheckBoxes=false;
    dt_tree=this.dt();
    Node node=new Node();
    InitTree(node,"0");
    UltraWebTree1.Nodes.Add(node);
   }
  }

  private DataTable dt()
  {
   DataTable dt=new DataTable("dt_tree");
   dt.Columns.Add("parentID");   
   dt.Columns.Add("value");
   dt.Columns.Add("id");

   dt.Rows.Add(new string[]{"0","计算机","0"});
   dt.Rows.Add(new string[]{"0","软件","1"});
   dt.Rows.Add(new string[]{"0","操作系统","2"});
   dt.Rows.Add(new string[]{"1","vs.net","3"});
   dt.Rows.Add(new string[]{"1","sql server","4"});
   dt.Rows.Add(new string[]{"2","window","5"});
   return dt;
  }

  private void InitTree(Node node,string ID)
  {   
   dv=new DataView();
   dv.Table=dt_tree;
   dv.RowFilter="parentID='"+ID+"'";
   
   foreach(DataRowView dr in dv )
   {
    Node node1=new Node();
    string controlText="<input type=checkbox name=ocean value={0}>{1}</input>";
    string s1=dr["value"].ToString();
    string s2=dr["id"].ToString();   
    controlText=string.Format(controlText,s2,s1);
    node1.Text=controlText;
   
    node.Expanded=true;
    node.Nodes.Add(node1);
    //递归
    if(dr["id"].ToString()!=ID)
    {
     string id=dr["id"].ToString();
     InitTree(node1,id);
    }
   }
  }

  #region Web Form Designer generated code
  override protected void OnInit(EventArgs e)
  {
   //
   // CODEGEN: This call is required by the ASP.NET Web Form Designer.
   //
   InitializeComponent();
   base.OnInit(e);
  }
  
  /// <summary>
  /// Required method for Designer support - do not modify
  /// the contents of this method with the code editor.
  /// </summary>
  private void InitializeComponent()
  {
   this.Load += new System.EventHandler(this.Page_Load);
  }
  #endregion 
 }
}

 

HTML部分

 <%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="webtree1.WebForm1" %>
<%@ Register TagPrefix="ignav" Namespace="Infragistics.WebUI.UltraWebNavigator" Assembly="Infragistics.WebUI.UltraWebNavigator.v4.3, Version=4.3.20043.27, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
 <HEAD>
  <title>WebForm1</title>
  <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
  <meta content="C#" name="CODE_LANGUAGE">
  <meta content="JavaScript" name="vs_defaultClientScript">
  <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
 </HEAD>
 <body MS_POSITIONING="GridLayout">
  <form id="Form1" method="post" runat="server">
   <FONT face="宋体">
    <ignav:ultrawebtree id="UltraWebTree1" runat="server" HoverClass="Hover" DisabledClass="DisabledClass"
     CompactRendering="False" Cursor="default" Font-Names="Verdana" Font-Size="8pt" RenderAnchors="False"
     JavaScriptFileNameCommon="ig_scripts/ig_csom.js" JavaScriptFilename="ig_scripts/ig_webtree.js" AutoPostBack="True"
     CollapseImage="ig_treeMinus.gif" ExpandImage="ig_treePlus.gif" Indentation="20" BrowserTarget="Auto"
     HiliteClass="HiliteClass" Expandable="True" FileFlags="StylesAndItems" Selectable="false" ImageDirectory="ig_images/"
     Height="325px" Width="100%" CheckBoxes="true"></ignav:ultrawebtree>
    <asp:Button id="Button1" style="Z-INDEX: 101; LEFT: 211px; POSITION: absolute; TOP: 134px" runat="server"
     Text="Button"></asp:Button><INPUT style="Z-INDEX: 102; LEFT: 232px; POSITION: absolute; TOP: 196px" type="button"
     value="Button" οnclick="win()"></FONT>
   <script>     
function getSelectedValue()
{
 var controls=document.all["ocean"];
 var temp="";
 for(var i=0;i<controls.length;i++)
 {  
  if(controls[i].checked)
  {
   temp+=controls[i].value+",";
  }
 }
 if(temp.length>0)
 {
  temp=temp.substring(0,temp.length-1);
 }
 return temp;
}

function win()
{
alert(getSelectedValue());
}
   </script>
  </form>
 </body>
</HTML>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值