Asp.net中有两个框架,左边是treeview,右边是显示页面,单击左边节点时,将相应的面页加载到右边?
1个回答
展开全部
个人认为最好用JS实现,这样无刷新,效果好,例子如下,
<script type="text/javascript" src="../dtree/jquery.js"></script>
<script type="text/javascript" src="../dtree/dtree.js"></script>
<link type="text/css" href="../dtree/dtree.css" rel="Stylesheet" />
<script type="text/javascript">
mytree=new dTree('mytree');
$.ajax({
url:'user.xml?'+Math.random(),
type:'GET', //数据发送方式
dataType:'xml', //接受数据格式
error:function(xml){
alert( "xml load error!");
},
async: false ,//同步方式
success: function(xml){
$(xml).find("node").each(function(){
var nodeId=$(this).attr("id");
var parentId=$(this).attr("pid");
var hrefAddress=$(this).attr("url");
var nodeName=$(this).attr("nodename");
mytree.add(nodeId,parentId,nodeName,hrefAddress,"","mainFrame","","",false);
//mainFrame是框架frameset的id name属性,采用框架布局
});
}
});
window.onload=function(){
document.getElementById("divdtree").innerHTML=mytree;
}
</script>
<div id="divdtree">
xml 文件如下
<node id="1" pid="-1" nodename="操作">
<node id="2" pid="1" nodename="监测数据处理">
<node id="22" pid="2" nodename="数据查询" >
<node id="2201" pid="22" nodename="常规查询" url="RwList.aspx"></node>
<node id="2202" pid="22" nodename="曲线查询" url="chartData.aspx"></node>
</node>
</node>
<node id="3" pid="1" nodename="污染源">
<node id="33" pid="3" nodename="废水比对" url="javascript:alert('未加载模块')" ></node>
<node id="34" pid="3" nodename="废水比对" url="javascript:alert('未加载模块')" ></node>
</node>
</node>
<script type="text/javascript" src="../dtree/jquery.js"></script>
<script type="text/javascript" src="../dtree/dtree.js"></script>
<link type="text/css" href="../dtree/dtree.css" rel="Stylesheet" />
<script type="text/javascript">
mytree=new dTree('mytree');
$.ajax({
url:'user.xml?'+Math.random(),
type:'GET', //数据发送方式
dataType:'xml', //接受数据格式
error:function(xml){
alert( "xml load error!");
},
async: false ,//同步方式
success: function(xml){
$(xml).find("node").each(function(){
var nodeId=$(this).attr("id");
var parentId=$(this).attr("pid");
var hrefAddress=$(this).attr("url");
var nodeName=$(this).attr("nodename");
mytree.add(nodeId,parentId,nodeName,hrefAddress,"","mainFrame","","",false);
//mainFrame是框架frameset的id name属性,采用框架布局
});
}
});
window.onload=function(){
document.getElementById("divdtree").innerHTML=mytree;
}
</script>
<div id="divdtree">
xml 文件如下
<node id="1" pid="-1" nodename="操作">
<node id="2" pid="1" nodename="监测数据处理">
<node id="22" pid="2" nodename="数据查询" >
<node id="2201" pid="22" nodename="常规查询" url="RwList.aspx"></node>
<node id="2202" pid="22" nodename="曲线查询" url="chartData.aspx"></node>
</node>
</node>
<node id="3" pid="1" nodename="污染源">
<node id="33" pid="3" nodename="废水比对" url="javascript:alert('未加载模块')" ></node>
<node id="34" pid="3" nodename="废水比对" url="javascript:alert('未加载模块')" ></node>
</node>
</node>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询