关闭

Infragistics web tree的应用(例子一)

标签: treewebstringwebformbuttonmicrosoft
1742人阅读 评论(0) 收藏 举报
分类:

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" onclick="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

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:4838次
    • 积分:83
    • 等级:
    • 排名:千里之外
    • 原创:2篇
    • 转载:0篇
    • 译文:0篇
    • 评论:0条
    文章分类
    文章存档