asp.NET2.0 的TreeView控件

本文介绍了一个使用 ASP.NET TreeView 控件的具体实例,展示了如何通过设置不同节点样式和图片来构建一个层次分明的导航菜单。示例中包含了多个层次的节点,并为每个节点设置了链接。
<%@ Page Language="C#" %>

<html xmlns="http://www.w3.org/1999/xhtml">
  <head runat="server">
    <title>TreeView w/ Line Images</title>
  </head>
  <body>
    <div>
      <h2>TreeView w/ Line Images</h2>

        <form action="treeview04_lines_cs.aspx" runat="server">

          <asp:TreeView ID="TreeView"
            RootNodeStyle-ImageUrl="~/images/xp/computer.gif"
            ParentNodeStyle-ImageUrl="~/images/xp/folder.gif"
            LeafNodeStyle-ImageUrl="~/images/xp/ie.gif"
            LineImagesFolder="~/images/lines"
            ShowLines="true"
            runat="server">

            <NodeStyle Font-Names="Arial" Font-Size="8pt" ForeColor="DarkBlue" HorizontalPadding="5"/>
            <RootNodeStyle Font-Bold="True" Font-Size="9pt"/>
            <HoverNodeStyle Font-Underline="True"/>
            <Nodes>
              <asp:TreeNode Text="My Computer">
                <asp:TreeNode Text="Favorites" ImageUrl="~/images/xp/star.gif">
                  <asp:TreeNode Text="News"> 
                    <asp:TreeNode Text="MSN" NavigateUrl="http://www.msn.com"/>
                    <asp:TreeNode Text="MSNBC News" NavigateUrl="http://www.msnbc.msn.com"/>
                  </asp:TreeNode>
                  <asp:TreeNode Text="Technology"> 
                    <asp:TreeNode Text="Microsoft" NavigateUrl="http://www.microsoft.com"/>
                    <asp:TreeNode Text="ASP.NET" NavigateUrl="http://www.asp.net"/>
                    <asp:TreeNode Text="GotDotNet" NavigateUrl="http://www.gotdotnet.com"/>
                    <asp:TreeNode Text="MSDN" NavigateUrl="http://msdn.microsoft.com"/>
                  </asp:TreeNode>
                  <asp:TreeNode Text="Shopping"> 
                    <asp:TreeNode Text="MSN Shopping" NavigateUrl="http://shopping.msn.com"/>
                    <asp:TreeNode Text="MSN Autos" NavigateUrl="http://autos.msn.com"/>
                  </asp:TreeNode>
                </asp:TreeNode>
                <asp:TreeNode Text="City Links">
                  <asp:TreeNode Text="MapPoint" NavigateUrl="http://www.mappoint.com"/>
                  <asp:TreeNode Text="MSN City Guides" NavigateUrl="http://local.msn.com"/>
                </asp:TreeNode>
                <asp:TreeNode Text="Music Links">
                  <asp:TreeNode Text="MSN Music" NavigateUrl="http://music.msn.com"/>
                </asp:TreeNode>
              </asp:TreeNode>
            </Nodes>
          </asp:TreeView>

      </form>
    </div>
  </body>
</html>

转载于:https://www.cnblogs.com/yefei520/archive/2006/03/10/347153.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值