{"id":245789,"date":"2022-07-03T10:10:58","date_gmt":"2022-07-03T02:10:58","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=245789"},"modified":"2022-06-23T18:14:05","modified_gmt":"2022-06-23T10:14:05","slug":"introduction-to-navigation","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/introduction-to-navigation.html","title":{"rendered":"ASP.NET Web Forms – \u5bfc\u822a\u7b80\u4ecb"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\nASP.NET \u5e26\u6709\u5185\u5efa\u7684\u5bfc\u822a\u63a7\u4ef6\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\"\"<\/p>\n

\u7f51\u7ad9\u5bfc\u822a<\/strong><\/span><\/div>\n

\u7ef4\u62a4\u5927\u578b\u7f51\u7ad9\u7684\u83dc\u5355\u662f\u56f0\u96be\u800c\u4e14\u8d39\u65f6\u7684\u3002<\/p>\n

\u5728 ASP.NET \u4e2d\uff0c\u83dc\u5355\u53ef\u5b58\u50a8\u5728\u6587\u4ef6\u4e2d\uff0c\u8fd9\u6837\u6613\u4e8e\u7ef4\u62a4\u3002\u6587\u4ef6\u901a\u5e38\u540d\u4e3a web.sitemap\uff0c\u5e76\u4e14\u88ab\u5b58\u653e\u5728\u7f51\u7ad9\u7684\u6839\u76ee\u5f55\u4e0b\u3002<\/p>\n

\u6b64\u5916\uff0cASP.NET \u6709\u4e09\u4e2a\u5fc3\u7684\u5bfc\u822a\u63a7\u4ef6\uff1a<\/p>\n

    \n
  1. Dynamic menus<\/li>\n
  2. TreeViews<\/li>\n
  3. Site Map Path<\/li>\n<\/ol>\n
    Sitemap \u6587\u4ef6<\/strong><\/span><\/div>\n

    \u5728\u672c\u6559\u7a0b\u4e2d\uff0c\u4f7f\u7528\u4e0b\u9762\u7684 sitemap \u6587\u4ef6\uff1a<\/p>\n

    \r\n<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\r\n<siteMap>\r\n<siteMapNode title=\"Home\" url=\"\/aspnet\/w3home.aspx\">
    \r\n<siteMapNode title=\"Services\" url=\"\/aspnet\/w3services.aspx\"> \r\n<siteMapNode title=\"Training\" url=\"\/aspnet\/w3training.aspx\"\/>\r\n<siteMapNode title=\"Support\" url=\"\/aspnet\/w3support.aspx\"\/>\r\n<\/siteMapNode>\r\n<\/siteMapNode>\r\n<\/siteMap><\/pre>\n

    \u521b\u5efa sitemap \u6587\u4ef6\u7684\u89c4\u5219\uff1a<\/p>\n

      \n
    • XML \u6587\u4ef6\u5fc5\u987b\u5305\u542b \u56f4\u7ed5\u5185\u5bb9\u7684 <siteMap> \u6807\u7b7e<\/li>\n
    • <siteMap> \u6807\u7b7e\u53ea\u80fd\u6709\u4e00\u4e2a <siteMapNode> \u5b50\u8282\u70b9\uff08 \"home\" \u9875\u9762\uff09<\/li>\n
    • \u6bcf\u4e2a <siteMapNode> \u53ef\u4ee5\u6709\u591a\u4e2a\u5b50\u8282\u70b9\uff08\u7f51\u9875\uff09<\/li>\n
    • \u6bcf\u4e2a <siteMapNode> \u5e26\u6709\u5b9a\u4e49\u9875\u9762\u6807\u9898\u548c URL \u7684\u5c5e\u6027<\/li>\n<\/ul>\n

      \u6ce8\u91ca\uff1asitemap \u6587\u4ef6\u5fc5\u987b\u4f4d\u4e8e\u7ad9\u70b9\u6839\u76ee\u5f55\u4e0b\uff0cURL \u5c5e\u6027\u5fc5\u987b\u76f8\u5bf9\u4e8e\u8be5\u6839\u76ee\u5f55\u3002<\/p>\n

      \u52a8\u6001\u83dc\u5355<\/strong><\/span><\/div>\n

      <asp:Menu> \u63a7\u4ef6\u53ef\u663e\u793a\u6807\u51c6\u7684\u7ad9\u70b9\u5bfc\u822a\u83dc\u5355\u3002<\/p>\n

      \u4ee3\u7801\u5b9e\u4f8b\uff1a<\/p>\n

      \r\n<asp:SiteMapDataSource id=\"nav1\" runat=\"server\" \/>\r\n<form runat=\"server\">\r\n<asp:Menu runat=\"server\" DataSourceId=\"nav1\" \/>\r\n<\/form><\/pre>\n

      \u4e0a\u9762\u5b9e\u4f8b\u4e2d\u7684 <asp:Menu><\/b> \u63a7\u4ef6\u662f\u4e00\u4e2a\u4f9b\u670d\u52a1\u5668\u521b\u5efa\u5bfc\u822a\u83dc\u5355\u7684\u5360\u4f4d\u7b26\u3002<\/p>\n

      \u63a7\u4ef6\u7684\u6570\u636e\u6e90\u7531 DataSourceId<\/b> \u5c5e\u6027\u5b9a\u4e49\u3002
      \nid=\"nav1\"<\/b> \u628a\u6570\u636e\u6e90\u8fde\u63a5\u5230 <asp:SiteMapDataSource><\/b> \u63a7\u4ef6\u3002<\/p>\n

      \u63a7\u4ef6\u7684\u6570\u636e\u6e90\u7531 DataSourceId \u5c5e\u6027\u5b9a\u4e49\u3002 id=\"nav1\" \u628a\u6570\u636e\u6e90\u8fde\u63a5\u5230 <asp:SiteMapDataSource><\/b>\u63a7\u4ef6\u3002<\/p>\n

      <asp:SiteMapDataSource><\/b> \u63a7\u4ef6\u81ea\u52a8\u8fde\u63a5\u9ed8\u8ba4\u7684 sitemap \u6587\u4ef6\uff08web.sitemap<\/b>\uff09\u3002<\/p>\n

      TreeView<\/strong><\/span><\/div>\n

      <asp:TreeView> \u63a7\u4ef6\u53ef\u663e\u793a\u591a\u7ea7\u5bfc\u822a\u83dc\u5355\u3002<\/p>\n

      \u8fd9\u79cd\u83dc\u5355\u770b\u4e0a\u53bb\u50cf\u4e00\u68f5\u5e26\u6709\u679d\u53f6\u7684\u6811\uff0c\u53ef\u901a\u8fc7 + \u6216 - \u7b26\u53f7\u6765\u6253\u5f00\u6216\u5173\u95ed\u3002<\/p>\n

      \u4ee3\u7801\u5b9e\u4f8b\uff1a\u8fd9\u79cd\u83dc\u5355\u770b\u4e0a\u53bb\u50cf\u4e00\u68f5\u5e26\u6709\u679d\u53f6\u7684\u6811\uff0c\u53ef\u901a\u8fc7 + \u6216 - \u7b26\u53f7\u6765\u6253\u5f00\u6216\u5173\u95ed\u3002<\/p>\n

      \u4ee3\u7801\u5b9e\u4f8b\uff1a<\/p>\n

      \r\n<asp:SiteMapDataSource id=\"nav1\" runat=\"server\" \/>\r\n<form runat=\"server\">\r\n<asp:TreeView runat=\"server\" DataSourceId=\"nav1\" \/>\r\n<\/form><\/pre>\n

      \u4e0a\u9762\u5b9e\u4f8b\u4e2d\u7684 <asp:TreeView><\/b> \u63a7\u4ef6\u662f\u4e00\u4e2a\u4f9b\u670d\u52a1\u5668\u521b\u5efa\u5bfc\u822a\u83dc\u5355\u7684\u5360\u4f4d\u7b26\u3002<\/p>\n

      \u63a7\u4ef6\u7684\u6570\u636e\u6e90\u7531 DataSourceId<\/b> \u5c5e\u6027\u5b9a\u4e49\u3002
      \nid=\"nav1\"<\/b> \u628a\u6570\u636e\u6e90\u8fde\u63a5\u5230 <asp:SiteMapDataSource><\/b> \u63a7\u4ef6\u3002<\/p>\n

      <asp:SiteMapDataSource><\/b> \u63a7\u4ef6\u81ea\u52a8\u8fde\u63a5\u9ed8\u8ba4\u7684 sitemap \u6587\u4ef6\uff08web.sitemap<\/b>\uff09\u3002<\/p>\n

      SiteMapPath<\/strong><\/span><\/div>\n

      SiteMapPath \u63a7\u4ef6\u53ef\u663e\u793a\u6307\u5411\u5f53\u524d\u9875\u9762\u7684\u6307\u9488\uff08\u5bfc\u822a\u8def\u5f84\uff09\u3002\u8be5\u8def\u5f84\u663e\u793a\u4e3a\u6307\u5411\u4e0a\u7ea7\u9875\u9762\u7684\u53ef\u70b9\u51fb\u94fe\u63a5\u3002<\/p>\n

      \u4e0e TreeView \u548c Menu \u63a7\u4ef6\u4e0d\u540c\uff0cSiteMapPath \u63a7\u4ef6\u4e0d\u4f7f\u7528 SiteMapDataSource\u3002SiteMapPath \u63a7\u4ef6\u9ed8\u8ba4\u4f7f\u7528 web.sitemap \u6587\u4ef6\u3002<\/p>\n

      lamp\u63d0\u793a\uff1a\u5982\u679c SiteMapPath \u6ca1\u6709\u6b63\u786e\u663e\u793a\uff0c\u5f88\u53ef\u80fd\u662f\u7531\u4e8e web.sitemap \u6587\u4ef6\u4e2d\u5b58\u5728 URL \u9519\u8bef\uff08\u6253\u5370\u9519\u8bef\uff09\u3002<\/p>\n

      \u4ee3\u7801\u5b9e\u4f8b\uff1a<\/p>\n

      \r\n<form runat=\"server\">\r\n<asp:SiteMapPath runat=\"server\" \/>\r\n<\/form><\/pre>\n

      \u4e0a\u9762\u5b9e\u4f8b\u4e2d\u7684 <asp:SiteMapPath><\/b> \u63a7\u4ef6\u662f\u4e00\u4e2a\u4f9b\u670d\u52a1\u5668\u521b\u5efa\u5bfc\u822a\u83dc\u5355\u7684\u5360\u4f4d\u7b26\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

      \u7ef4\u62a4\u5927\u578b\u7f51\u7ad9\u7684\u83dc\u5355\u662f\u56f0\u96be\u800c\u4e14\u8d39\u65f6\u7684\u3002 \u5728 ASP.NET \u4e2d\uff0c\u83dc\u5355\u53ef\u5b58\u50a8\u5728\u6587\u4ef6\u4e2d\uff0c\u8fd9\u6837\u6613\u4e8e\u7ef4\u62a4\u3002\u6587\u4ef6\u901a\u5e38\u540d\u4e3a […]<\/p>\n","protected":false},"author":1470,"featured_media":245793,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-245789","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/245789","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1470"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=245789"}],"version-history":[{"count":3,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/245789\/revisions"}],"predecessor-version":[{"id":245796,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/245789\/revisions\/245796"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/245793"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=245789"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=245789"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=245789"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}