MyTree树控件_Ajax实现异步加载节点
最近一直在寻找一个比较方便好用的树控件,MyTree树控件并没有提供很多其他的功能,但在Ajax异步加载节点上实现的很简洁,留作备忘。
MyTree的下载地址:http://www.itplus.com.cn/myTree/
下载后 Demo:Ajax异步加载例子
Document:文档
myTree:放项目里要引用的文件
MytreeTest.aspx页
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MytreeTest.aspx.cs" Inherits="VistaToNewSchol.MytreeTest" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
<script language="javascript" src="../myTree/myTree.js"></script>
<script language="javascript" src="../myTree/bingo.js"></script>
<script language="javascript">
var tree;
window.onload = function(){
tree = new myTree("myFirstTree", "divTree", "../myTree/", "Blue");
tree.datafrom = "MyTreeGetNode.aspx"
tree.load();
}
function myFirstTree_onClick(prmNodeId){
tree.load(prmNodeId);
tree.expandNode(prmNodeId);
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div id="divTree"></div>
<div id="divStr"></div>
</form>
</body>
</html>
&
相关文档:
/*在有中文参数时,接收方需要使用UTF-8方式对数据进行解码
*不支持post附件
*/
function getXmlHttpRequest() {
var xmlHttpRequest = null;
try {
xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");
} ......
页面代码:
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManage ......
ScriptManager.RegisterStartupScript(p1, this.GetType(), "click", "alert('ok')", true);//p1是updatepanel的id
ScriptManager.RegisterStartupScript(p1, this.GetType(), "click", "alert('ok')", true);//p1是updatepanel的id
......
由于安全问题的考虑,Ajax(xmlhttprequest)默认是不支持跨域调用的。比如在www.cadal.com去请求www.test.cadal.com的数据,都是不行的。
解决方案有很多,总结如下:
参考:
1.利用<script>标签
Difficult to know when the content is available, no standard methodology, can be considered a "security risk" ......
文件名:ajax.js
/**
* 取得当前页面的url
* 可以在调用ajax_query前修改
**/
var url = location.href.substr(0, location.href.length-location.search.length);
/**
* 给Function对象添加一个取得函数名的方法
**/
Function.prototype.Name = function() {
var s = Func ......