·您现在的位置: 云翼网络 >> 文章中心 >> 网站建设 >> 网站建设开发 >> ASP.NET网站开发 >> ASP.NET2.0自动搜索文件组成导航系统

ASP.NET2.0自动搜索文件组成导航系统

作者:佚名      ASP.NET网站开发编辑:admin      更新时间:2022-07-23

asp.net2.0的导航系统确实给web开发带来方便,但是用过的用户就会发现导航系统有一个很大的缺陷:他需要你手工编写web.sitemap,web.sitemap的语法用语句流行话是“相当的简单”,但是实际运用时,虽然简单,但是稍微复杂的导航,你肯定出错。为什么?下面是一个简单的sitemap,

<siteMap>
  <siteMapNode title="Home" url="~/default.aspx" >
    <siteMapNode title="Introduction to ASP.NET" url="~/introduction/default.aspx">
    <siteMapNode title="What's New in Whidbey?" url="~/introduction/whatsnew.aspx"/>
      <siteMapNode title="Sample applications (Starter Kits)" url="~/introduction/starterkits.aspx"/>
      <siteMapNode title="Introduction to Visual Web Developer" url="~/introduction/vwd.aspx"/>
    </siteMapNode>
    <siteMapNode title="Building A Web Application" url="~/development/default.aspx">
      <siteMapNode title="Building a Simple Application" url="~/development/simple/default.aspx">
        <siteMapNode title="Introduction to ASP.NET pages" url="~/development/simple/pages.aspx"/>
        <siteMapNode title="Introduction to Server Controls" url="~/development/simple/servercontrols.aspx"/>
        <siteMapNode title="Inline vs Code Behind Pages" url="~/development/simple/codeseparation.aspx"/>
        <siteMapNode title="Sharing Code Between Pages" url="~/development/simple/codedirectory.aspx"/>
      </siteMapNode>
</siteMap>

    说白了,他只是一些siteMapNode 的嵌套,但是嵌套的开闭呼应对人而言,绝对是一个烦点,但是对计算机来说,就喜欢处理这些简单的关系,所以我们可以编写一个文件,让系统自动检索当前应用程序的页面并自动生成导航。
miclae就写了一篇文章,我已经将他用C#改写并编译为DLL文件,现在 你只要把该DLL文件拷贝到你项目的bin目录下。并设置导航控件(menu,treeview)为引用该DLL,运行时,系统将自动根据你的目录文件自动生成导航系统。
当然,该DLL文件的功能远远不只这些,他会自动去掉APP_*和bin目录,如果你愿意,你完全可以在web.config里配制他,告诉dll 不要把某个目录进行现实等。
现在你在添加/删除文件时,再也不用修改web.sitemap

http://www.cnblogs.com/mqingqing123/archive/2006/09/04/494616.html