• 文章列表仅仅显示描述


    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;
       }
      }

  • 相关阅读:
    Fiddler抓包整理
    redis集群
    php性能加速:Opcache
    细说一下position(定位),以及其他的小知识
    css的小知识3
    css小知识 2
    网页背景的属性及使用
    css小知识
    属性的特征和一些选择器的使用
    浏览器介绍和一些简单的代码
  • 原文地址:https://www.cnblogs.com/ZhengGuoQing/p/1370502.html
Copyright © 2020-2023  润新知