zoukankan      html  css  js  c++  java
  • 文章列表仅仅显示描述

    private static Regex _Regex = new Regex("<[^>]*>", RegexOptions.Compiled);

      private static string StripHtml(string html)
      {
       if (string.IsNullOrEmpty(html))
        return string.Empty;

       return _Regex.Replace(html, string.Empty);
      }

     public string Body
      {
       get
       {
        string body = Post.Content;
        if (ShowExcerpt)
        {
         string link = " <a href=\"" + Post.RelativeLink.ToString() + "\">[" + (Page as BlogBasePage).Translate("more") + "]</a>";

         if (!string.IsNullOrEmpty(Post.Description))
         {
          body = Post.Description + "." + link;
         }
         else
         {
          body = StripHtml(Post.Content);
          if (body.Length > 300)
           body = body.Substring(0, 300) + "..." + link;
         }
        }

        ServingEventArgs arg = new ServingEventArgs(body, this.Location);
        Post.OnServing(Post, arg);

        if (arg.Cancel)
        {
         if (arg.Location == ServingLocation.SinglePost)
         {
          Response.Redirect("~/error404.aspx", true);
         }
         else
         {
          this.Visible = false;
         }
        }

        return arg.Body;
       }
      }

  • 相关阅读:
    【扩展】1. PHP 大括号{} 的使用
    preg_replace 中修正符 e 的解析
    terminal 修改终端显示的名字
    find 命令详解
    OSI 7层结构 粗认识
    vi 全解析
    awk 学习笔记
    scp 复制远程文件 文件带空格 处理
    更新博客地址啦!!!
    ubuntu16.04安装NVIDIA驱动遇到的问题
  • 原文地址:https://www.cnblogs.com/ZhengGuoQing/p/1370502.html
Copyright © 2011-2022 走看看