目录结构
.aspx
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<asp:Menu ID="Menu1" runat="server" DataSourceID="XmlDataSource1" Orientation="Horizontal" BackColor="#F7F6F3" DynamicHorizontalOffset="2" Font-Names="Verdana" Font-Size="Small" ForeColor="#7C6F57" StaticSubMenuIndent="10px">
<DataBindings>
<asp:MenuItemBinding DataMember="Parent" NavigateUrlField="name" TextField="name" />
<asp:MenuItemBinding DataMember="Child" NavigateUrlField="name" TextField="name" />
</DataBindings>
<DynamicHoverStyle BackColor="#7C6F57" ForeColor="White" />
<DynamicMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
<DynamicMenuStyle BackColor="#F7F6F3" />
<DynamicSelectedStyle BackColor="#5D7B9D" />
<StaticHoverStyle BackColor="#7C6F57" ForeColor="White" />
<StaticMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
<StaticSelectedStyle BackColor="#5D7B9D" />
</asp:Menu>
<asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="~/XMLFile.xml" XPath="/*/*"></asp:XmlDataSource>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">
<asp:TreeView ID="TreeView2" runat="server" DataSourceID="SiteMapDataSource1" ImageSet="Arrows">
<HoverNodeStyle Font-Underline="True" ForeColor="#5555DD" />
<NodeStyle Font-Names="Tahoma" Font-Size="10pt" ForeColor="Black" HorizontalPadding="5px" NodeSpacing="0px" VerticalPadding="0px" />
<ParentNodeStyle Font-Bold="False" />
<SelectedNodeStyle Font-Underline="True" ForeColor="#5555DD" HorizontalPadding="0px" VerticalPadding="0px" />
</asp:TreeView>
<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" ShowStartingNode="False" />
</asp:Content>
web.config
<configuration>
<connectionStrings>
<remove name="LocalSqlServer"/>
<add name="LocalSqlServer" connectionString="server=(localdb)\MSSQLLocalDB;database=Test;uid=;pwd=;"/>
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.5.2" />
</system.web>
</configuration>
.sitemap
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url="" title="root" description="">
<siteMapNode url="" title="学院首页" description="" />
<siteMapNode url="" title="院情总览" description="classTwo">
<siteMapNode url="" title="学院简介"/>
<siteMapNode url="" title="现任领导"/>
<siteMapNode url="" title="办学条件"/>
</siteMapNode>
<siteMapNode url="" title="办学成就" description="" />
<siteMapNode url="" title="师资队伍" description="" />
<siteMapNode url="" title="学科专业" description="" />
<siteMapNode url="" title="教学管理" description="" />
<siteMapNode url="" title="科学研究" description="" />
<siteMapNode url="" title="合作交流" description="" />
<siteMapNode url="" title="招生就业" description="" />
<siteMapNode url="" title="党建思政" description="" />
<siteMapNode url="" title="学生园地" description="" />
</siteMapNode>
</siteMap>
<?xml version="1.0" encoding="utf-8" ?>
<Root url="" name="人工智能学院" describe="">
<Parent url="" name="学院首页" describe="" ></Parent>
<Parent url="" name="院情总览" describe="" >
<Child url="" name="学院简介" describe=""></Child>
<Child url="" name="现任领导" describe=""></Child>
<Child url="" name="办学条件" describe=""></Child>
</Parent>
<Parent url="" name="办学成就" describe="" ></Parent>
<Parent url="" name="师资队伍" describe="" ></Parent>
<Parent url="" name="学科专业" describe="" ></Parent>
<Parent url="" name="教学管理" describe="" ></Parent>
<Parent url="" name="科学研究" describe="" ></Parent>
<Parent url="" name="合作交流" describe="" ></Parent>
<Parent url="" name="招生就业" describe="" ></Parent>
<Parent url="" name="党建思政" describe="" ></Parent>
<Parent url="" name="学生园地" describe="" ></Parent>
</Root>

注意:
母版拖放后,有几个控件就加几个contentPlaceHolder

添加窗体勾选选择母版页

加上/*/*启动不显示根目录

Code<%@PageLanguage="C#"%><scriptrunat="server">protectedvoidMenu1_MenuItemClick(objectsender,MenuEventArgse){ListBox1.Items.Add(e.Item.Parent.Value+":"+e....
本人对WEB UI的设计工作做的很少,多数时间是在后端开发,这个例子做过了,记录下来,以后做个参考菜单效果如下菜单上面有鼠标经过的变背景色,和字体加粗变颜色的效果,不方便截图,这里就算了样式文件 topmenu.css.staticMenu
background-color: #e4f0ff;
font-family: Arial;
display: block;
protectedvoidBindMenuTree()
stringxmlPath=Server.MapPath("SiteMap/LeftMenu.sitemap");
XmlDocumentdoc=newXmlDocument();
母版页就是网站中一样的部分母版页的后缀名是.Master可以把母版页当成一个页面 想让哪里是别的内容就可以 通过如下: <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server"> </asp:ContentPlaceHolder>//相当于占位符 想改哪...
<?xml version="1.0" encoding="utf-8" ?>
<Area iAreaID ="0" cAreaName="城市">
<Province iAreaID ="1" cAreaName="北京市"/>
<Province iAreaID ="2" cAreaName="上海市"/>...