当前位置: 代码迷 >> ASP.NET >> 100分送下,了解ComponentArt控件原理的朋友进来看上
  详细解决方案

100分送下,了解ComponentArt控件原理的朋友进来看上

热度:3576   发布时间:2013-02-25 00:00:00.0
100分送上,了解ComponentArt控件原理的朋友进来看下
刚看了下ComponentArt的Callback控件,其它有个关于实现类似Windows资源管理器的例子。有个问题没有闹明白,请高人指点一下。

例子中,左边是一个ComponentArt的TreeView,是显示类似资源管理器中左边的目录结构,右边是ComponentArt的Grid控件,当点击了左边树上的结点(选中目录)的时候,选中节点下加载出他的子目录,右边Grid中显示出选中的节点(目录)下面的各种文件。而这个例子是用了两个页面来实现的。
首页代码过多不方便例出,基本是这样的,点击节点后,使用Ajax刷新了右边的Grid,但同时加载出选中节的子目录的功能是使用另外一个页面来实现的,代码如下:
HTML code
<%@ Page Language="C#" AutoEventWireUp="true" %><%@ import Namespace="System.Threading" %><%@ import Namespace="System.IO" %><%@ import Namespace="ComponentArt.Web.UI" %><% Response.ContentType = "text/xml"; %><script language="C#" runat="server">void Page_Load(Object sender,EventArgs e){  ComponentArt.Web.UI.TreeView TreeView1 = new ComponentArt.Web.UI.TreeView();  string dirPath = Request.QueryString["dir"];   dirPath = dirPath.Replace("~", "\\");   // Don't allow browsing  the file system outside of the app root   if (dirPath.StartsWith(Request.MapPath("~")))   {    string[] subDirectories = Directory.GetDirectories(dirPath);    foreach (string directory in subDirectories)    {      string[] parts = directory.Split('\\');      string name = parts[parts.Length-1];      ComponentArt.Web.UI.TreeViewNode node = new ComponentArt.Web.UI.TreeViewNode ();      node.Text = name;       node.ContentCallbackUrl = "XmlFromFileSystem.aspx?dir=" + directory.Replace("\\", "~");       node.ID = directory.Replace("\\", "~");       TreeView1.Nodes.Add(node);    }    Response.Write(TreeView1.GetXml());   }}</script>

我看了下,就是得到了TreeView的选中节点的子目录的节点集生成的XML。
我的问题是:
1、上面例子中在运行时浏览,感觉就是一个页面,与加载子目录页面看似没有任何关系。
2、生成子目录的页面生成的XML是如何传回主页面,让主页面把这个XML的内容加到TreeView中的?我发现ComponentArt控件不止一个使用了这个方式的处理,比如Component Chart图件等。
3、这是使用的什么原理。



------解决方案--------------------------------------------------------
ComponentArt的2007和asp.net ajax是不相容的,只研究了一下narbar..
------解决方案--------------------------------------------------------
ComponentArt提供了js和后台c#/VB两种方式构建节点。这两种方式都可以都可以根据xml的数据源来构造树。

我觉得下面这个属性
node.ContentCallbackUrl = "XmlFromFileSystem.aspx?dir=" + directory.Replace("\\", "~"); 
就是给ajax指定服务器端处理的URL。这个URL指向的页面把处理的结果用xml文件返回到客户端。客户端在用js组装出树。

你可以看看ComponentArt TreeView的另外几个直接通过js构建树的例子。然后再看看没有使用ajax框架,完全手写的js和服务器端交互的例子,估计就会明白了
  相关解决方案