父窗体页面放两个iframe
<html xmlns="[url]http://www.w3.org/1999/xhtml[/url]" >
<head runat="server">
<title>主框架</title>
<script language="javascript">
function closethis()
{
document.all.dir.style.display='none';
}
function openthis()
{
document.all.dir.style.display='';
}
</script>
</head>
<body>
<table border="0" width="100%" cellpadding="0" class="main-table">
<tr>
<td align="left" id=dir style="width:23%">
<iframe id="menu" name="menu" src="PublicCategory.aspx" class="inset-table" width="300" height="600" frameborder="NO" border="0" framespacing="0"></iframe> //左边菜单,这里将放一棵树型目录
</td>
<td width="2%" align=center><a href="javascript:closethis();"><=</a><br><br><br><a href="javascript:openthis();">=></a></td>
<td align="left" style="width:75%">
<iframe id="Right" name="Right" src="PublicContectPersonList.aspx" class="outset-table" width="100%" height="600" frameborder="NO" border="1" framespacing="0" noresize align=middle></iframe>// 右边详细页面,点击左边的树型目录得到
</td>
</tr>
</table>
</body>
</html>
左边目录子页面PublicCategory.aspx
前台:
<head runat="server">
<title>公有目录</title>
<link href="../../../Skin/<%=Session["_SkinPath"] %>/CSS/style.css" type="text/css" rel="stylesheet" />
</head>
<body>
<form id="form1" runat="server">
<div style="width:100%;">
<table class="main-table" style="width: 283; height: 100%">
<tr class="title">
<td align="left">目录列表:</td>
</tr>
<tr class="line-even" >
<td style="width: 100%" valign="top">
<asp:TreeView ID="tvCategory" runat="server" Height="560" ImageSet="Contacts" Width="283">
<Nodes>
<asp:TreeNode Text="公用通讯录" Value="公用通讯录">
<asp:TreeNode Text="新建节点" Value="新建节点">
<asp:TreeNode Text="新建节点" Value="新建节点"></asp:TreeNode>
</asp:TreeNode>
<asp:TreeNode Text="新建节点" Value="新建节点"></asp:TreeNode>
</asp:TreeNode>
</Nodes>
<SelectedNodeStyle BackColor="#C0FFFF" />
</asp:TreeView>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
后台:
public partial class PublicCategory : System.Web.UI.Page
{
DataTable dt = null;
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
int ispublic =1;//表示公有
this.initTree(dt);
}
}
/// <summary>
/// 初始化树
/// </summary>
/// <param name="dt">取得所有的目录</param>
private void initTree(DataTable dt)
{
this.tvCategory.Nodes.Clear();//先清理原先的
if (dt!=null&&dt.Rows.Count == 0) return;
DataRow[] Rows = dt.Select("parentID=0");
if (Rows.Length == 0) return;
foreach (DataRow row in Rows)
{
TreeNode tNode = new TreeNode();
tNode.Value = row["categoryID"].ToString();
tNode.Text = row["title"].ToString();
tNode.NavigateUrl = "PublicContectPersonList.aspx?categoryID=" + tNode.Value + "";
tNode.Target = "Right";//指向父窗体右边的那个iframe
createChildNode(tNode, tNode.Value);
}
/// <summary>
/// 创建子节点
/// </summary>
/// <param name="node"></param>
/// <param name="strParentNo"></param>
private void createChildNode(TreeNode node, string strParentNo)
{
DataRow[] Rows = dt.Select("parentID='" + Convert.ToInt32(strParentNo) + "'");
foreach (DataRow row in Rows)
{
TreeNode childNode = new TreeNode();
childNode.Target = "Right";//指向父窗体右边的那个iframe
childNode.Text = row["title"].ToString();
childNode.NavigateUrl = "PublicContectPersonList.aspx?categoryID=" + childNode.Value + "";
}
右边详细信息页面:PublicContectPersonList.aspx
这个页面就没什么好介绍的,通过刚才节点 tNode.NavigateUrl = "PublicContectPersonList.aspx?categoryID=" + tNode.Value + "";
childNode.NavigateUrl = "PublicContectPersonList.aspx?categoryID=" + childNode.Value + "";
传过来的节点id去数据库取数据绑定到GridView就可以