asp.net 4.5演習〜test12-6メニューニュース

web.sitemap

<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
  <siteMapNode  url="~/WebForm1.aspx" title="首页"  description="Home">

    <siteMapNode  url="~/News.aspx" title="新闻"  description="News" >
      <siteMapNode url="~/NewsFocus.aspx" title="焦点新闻" description=""/>
      <siteMapNode url="~/NewsInside.aspx" title="国内新闻" description=""/>
      <siteMapNode url="~/NewsOutside.aspx" title="国际新闻" description=""/>
    </siteMapNode>

    <siteMapNode  url="~/Finance.aspx" title="财经"  description="Finance" >
      <siteMapNode  url="~/Stock.aspx" title="股票"  description=""  />
      <siteMapNode  url="~/Money.aspx" title="理财"  description="" />
      <siteMapNode url="~/Exchange.aspx" title="外汇" description=""/>
      <siteMapNode url="~/Fund.aspx" title="基金" description=""/>
    </siteMapNode>

    <siteMapNode  url="~/Internet.aspx" title="互联网"  description="Internet" >
      <siteMapNode  url="~/baidu.aspx" title="百度"  description="" />
      <siteMapNode  url="~/wangyi.aspx" title="网易"  description="" />
    </siteMapNode>
  </siteMapNode>
</siteMap>

webform1.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="test12_6.WebForm1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Menu ID="Menu1" runat="server" BackColor="#F7F6F3" DataSourceID="SiteMapDataSource1" DynamicHorizontalOffset="2" Font-Names="Verdana" Font-Size="0.8em" ForeColor="#7C6F57" Orientation="Horizontal" StaticSubMenuIndent="10px">
            <DynamicHoverStyle BackColor="#7C6F57" ForeColor="White" />
            <DynamicMenuItemStyle HorizontalPadding="10px" VerticalPadding="10px" Width="100px" />
            <DynamicMenuStyle BackColor="#F7F6F3" />
            <DynamicSelectedStyle BackColor="#5D7B9D" />
            <StaticHoverStyle BackColor="#7C6F57" ForeColor="White" />
            <StaticMenuItemStyle HorizontalPadding="10px" VerticalPadding="10px" Width="100px" />
            <StaticMenuStyle Width="100px" />
            <StaticSelectedStyle BackColor="#5D7B9D" />
        </asp:Menu>
        <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />
    </div>
    </form>
</body>
</html>

web.config

<?xml version="1.0" encoding="utf-8"?>

<!--
  有关如何配置 ASP.NET 应用程序的详细信息,请访问
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->

<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />
    <siteMap defaultProvider="XmlSiteMapProvider1" enabled="true" >
      <providers>
        <clear/>
        <add name="XmlSiteMapProvider1" type="System.Web.XmlSiteMapProvider" siteMapFile="Web.sitemap"/>
      </providers>
    </siteMap>
  </system.web>

</configuration>

 

おすすめ

転載: blog.csdn.net/modern358/article/details/114700652