zoukankan      html  css  js  c++  java
  • 自动生成所有导航

            protected void Page_Load(object sender, EventArgs e)
            {
                string htmlSiteBar = string.Empty;
                string ulFormat = "<ul>{0}</ul>";
                string liFormat = "<li>{0}</li>";
                string aFormat = "<a href='{0}'>{1}</a>";
    
                foreach (string file in Directory.GetFiles(Server.MapPath("~"), "*.aspx", SearchOption.AllDirectories))
                {
                    string url = Page.ResolveClientUrl("~/" + SubRoot(file).Replace("\\", "/"));
                    htmlSiteBar += (string.Format(liFormat, string.Format(aFormat, url, SubRoot(file).Replace(".aspx", string.Empty).Replace("\\", "/"))));
                }
                htmlSiteBar = string.Format(ulFormat, htmlSiteBar);
                txtPages.Text = htmlSiteBar;
            }
            string SubRoot(string fullPath)
            {
                return fullPath.Replace(Server.MapPath("~"), string.Empty);
            }
    作者:KKcat
        
    个人博客:http://jinzhao.me/
        
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
  • 相关阅读:
    补交20145226蓝墨云班课 -- 程序设计中临时变量的使用
    补交20145226蓝墨云班课 -- MyCP
    补交20145226蓝墨云班课 -- MyOD
    补交20145226蓝墨云班课 -- Arrays和String单元测试
    补交20145226蓝墨云班课 -- 后缀表达式
    20145226夏艺华 《Java程序设计》 课堂实践
    20145226夏艺华 网络对抗技术 EXP9 web安全基础实践
    (转载)充分理解QML的属性绑定
    (转载)UML类图中的六大关系:关联、聚合、组合、依赖、继承、实现
    (转载)链路层MTU的概念?为什么MTU值普遍都是1500?
  • 原文地址:https://www.cnblogs.com/jinzhao/p/1454828.html
Copyright © 2011-2022 走看看