.net 2.0 ajax 树
是的,所以我必须在 asp.net 2.0 winforms 中构建一个 Web 应用程序。 我更喜欢 3.5 MVC。 因为它更干净、更精简、更现代,对我来说更有意义。 我很了解 3.5 MVC,并且有 Rails 背景,所以这个 Webforms 东西对我来说看起来有点恶心:P。
不管怎样,我需要一个支持 AJAX 的树控件,它可以在节点展开时通过 ajax 加载子树。
在 Asp MVC 中,我会做一些事情,比如制作一个代表单个节点的部分,以及一个 jQuery AJAX 触发的控制器操作,该操作呈现这些部分(子项)的集合,该集合被插入到目标的子项 div 的innerHTML 中。
AFAIC,在 .net 2.0 中我的选择是:
制作一个代表单个节点的 Webforms 控件。 使用 Asp AJAX 调用代码隐藏方法,该方法递归地添加代表此节点子节点的控件。 优点:非常适合官方的 asp 2.0 框架。 挺容易。 缺点: Web 表单很粗糙(:p),并且使得将此站点升级到 3.5 更高版本变得更加困难。
创建一个 webservices 方法,以 JSON 列表的形式返回子项,然后在客户端 javascript 中将其格式化为 HTML,使用 jQuery 进行请求和格式化。 优点:由于 json 的开销较低,速度很快。 更加面向未来,因为 json-webservices 可以轻松过渡到 MVC 控制器方法。 缺点:需要开发更多工作。 HTML 最终与客户端 javascript 混合在一起(因为没有可用的 JSON/javascript 模板),这很可怕(恕我直言)。
使用第三方网络控件。 优点:工作量最少(在最好的情况下)。 缺点:必须评估使用哪一个。 可能需要购买。 学习/处理控件api等
还有其他方式吗?
那么你们认为最好的方法是什么?
Right, so I have to build a web app in asp.net 2.0 winforms. Id much much much prefer 3.5 MVC. because its cleaner, leaner, more modern and makes more sense to me. I know 3.5 MVC well, and have come from a Rails background, so this webforms stuff looks kinda gross to me :P.
Anyway, I need an AJAX-backed tree control, one that loads the subtrees via ajax when nodes are expanded.
In Asp MVC i would do something like making a partial representing a single node, and a jQuery AJAX triggered controller action that renders a collection of these partials(the children) which is inserted into the target's children div's innerHTML.
AFAIC, in .net 2.0 my options are:
Make a Webforms control that represents a single node. Use Asp AJAX to call a codebehind method that recursivley adds controls representing the children of this node.
Pros: fits well within the offical asp 2.0 framework. Pretty easy. Cons: webforms are gross(:p), and makes upgrading this site to 3.5 later much harder.Make a webservices method that returns the children as a JSON list, which are then formatted to HTML in client-side javascript, using jQuery for the requesting and formatting. Pros: Speedy due to low overheads with json. More future-proof, as json-webservices easily transition to MVC controller methods. Cons: More work to develop. HTML ends up mixed up in with the clientside javascript(because theres no JSON/javascript templating availible), which is hideous(IMHO).
use a third party web control. Pros: least work(in best case). Cons: have to evalutate which one to use. may have to purchase. Learning/dealing with control api, etc.
Some other way?
So what do you guys think is the best way to go?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
jstree.com
jstree.com
我一直在使用 ComponentArt 的树视图。 很容易拿起。 控件中的 Web 服务支持当前已完成; 但是,它确实允许您查询 url,并且它需要一个简单的 xml 文档,并将其转换为客户端对象。 非常容易和快速地获得一个功能齐全的良好控制并非常快速地运行。
对于服务器端,我创建了一个 ASHX 页面,它有助于将服务器端开销降至最低。
I've been using ComponentArt's tree view. It was preety easy to pick up. The webservices support in the control is hosed currently; however, it does allow you to query a url, and it expects a simple xml document which it translates to its client side objects. Very easy and quick to get a nice fully functional conrol up and running very quickly.
For the server side I created an ASHX page which helps keep the server side overhead down to a minimum.