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

相关文章:

  • 2022-12-23
  • 2021-06-07
  • 2022-12-23
  • 2022-01-08
  • 2022-12-23
  • 2021-05-19
猜你喜欢
  • 2021-10-08
  • 2022-01-23
  • 2021-11-05
  • 2021-07-02
  • 2021-07-29
  • 2021-12-04
相关资源
相似解决方案