从数据库读出的字段,比如新闻的格式,要做简要显示的时候,需要去掉格式,只显示文本,以下是整理的一个方法,更新中。。。
测试环境:VS2005+.NET 2.0 +C#
1、引用using System.Text.RegularExpressions
2、主要方法
1数据库读出的HTML格式过滤的方法public string RemoveHtml(string strHtml)   
2    }
3、全部代码,包括后台:
 1数据库读出的HTML格式过滤的方法using System;
 2数据库读出的HTML格式过滤的方法using System.Data;
 3数据库读出的HTML格式过滤的方法using System.Configuration;
 4数据库读出的HTML格式过滤的方法using System.Web;
 5数据库读出的HTML格式过滤的方法using System.Web.Security;
 6数据库读出的HTML格式过滤的方法using System.Web.UI;
 7数据库读出的HTML格式过滤的方法using System.Web.UI.WebControls;
 8数据库读出的HTML格式过滤的方法using System.Web.UI.WebControls.WebParts;
 9数据库读出的HTML格式过滤的方法using System.Web.UI.HtmlControls;
10数据库读出的HTML格式过滤的方法using System.Text.RegularExpressions;
11数据库读出的HTML格式过滤的方法
12数据库读出的HTML格式过滤的方法public partial class _Default : System.Web.UI.Page 
13}
前台:
 1数据库读出的HTML格式过滤的方法<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" ValidateRequest="false" %>
 2数据库读出的HTML格式过滤的方法
 3数据库读出的HTML格式过滤的方法<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 4数据库读出的HTML格式过滤的方法
 5数据库读出的HTML格式过滤的方法<html xmlns="http://www.w3.org/1999/xhtml" >
 6数据库读出的HTML格式过滤的方法<head runat="server">
 7数据库读出的HTML格式过滤的方法    <title>无标题页</title>
 8数据库读出的HTML格式过滤的方法</head>
 9数据库读出的HTML格式过滤的方法<body>
10数据库读出的HTML格式过滤的方法    <form id="form1" runat="server">
11数据库读出的HTML格式过滤的方法    <div>
12数据库读出的HTML格式过滤的方法        <asp:TextBox ID="TextBox1" runat="server" Rows="5" TextMode="MultiLine" Width="434px"></asp:TextBox><br />
13数据库读出的HTML格式过滤的方法        <asp:Button ID="btnFilterHtml" runat="server" OnClick="btnFilterHtml_Click" Text="过滤掉标签" /><br />
14数据库读出的HTML格式过滤的方法        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
15数据库读出的HTML格式过滤的方法        <hr />
16数据库读出的HTML格式过滤的方法        <asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
17数据库读出的HTML格式过滤的方法    </div>
18数据库读出的HTML格式过滤的方法    </form>
19数据库读出的HTML格式过滤的方法</body>
20数据库读出的HTML格式过滤的方法</html>
21数据库读出的HTML格式过滤的方法
---可以直接复制运行

相关文章:

  • 2021-05-06
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-21
  • 2021-09-08
  • 2021-11-10
  • 2021-06-24
猜你喜欢
  • 2021-06-28
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-11
相关资源
相似解决方案