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