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/
        
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
  • 相关阅读:
    多线程执行有返回值有参数的方法
    当连续进行多个请求,并且请求的url地址相同时。放弃前面的所有请求,只执行最后一次请求。
    防止重复发送Ajax请求的解决方案
    多行文本溢出显示省略号
    h5 文件跨域上传
    完美解决 IOS系统safari5.0 浏览器页面布局iframe滚动条失效问题,iossafari5.0
    CSS3 修改和去除移动端点击事件出现的背景框 (tap-highlight-color)
    去除img之间的空白
    手机上点击a标签是出现阴影解决办法
    idea通过maven构建springMVC+mybatis项目
  • 原文地址:https://www.cnblogs.com/jinzhao/p/1454828.html
Copyright © 2011-2022 走看看