asp.net如何去掉HTML标记
来源:互联网 发布:gcc编译器linux下载 编辑:程序博客网 时间:2024/05/17 03:48
今天突然被问到 从数据库里读出来数据时有的时候会带有HTML的标签,而且如果把数据装在TextBox这类的容器里的时候标签会成为字符串输出来,这样肯定不是自己要的效果,那么如何去掉这些个HTML标签嘞!
protected void Button1_Click(object sender, EventArgs e) { string str=ConfigurationManager.ConnectionStrings["sqlstr"].ConnectionString; using (SqlConnection sqlcon = new SqlConnection(str)) { using (SqlCommand sqlcom = sqlcon.CreateCommand()) { sqlcom.CommandText = "select * from T_Blog where Uname='Mary'"; sqlcon.Open(); SqlDataReader reader = sqlcom.ExecuteReader(); if (reader.Read()) { string content = reader["Bcontent"].ToString(); //声明一个不可变的正则表达式
Regex regex = new Regex("<.+?>"); content = regex.Replace(content, ""); this.TextBox1.Text = content; } } } }
使用的正则“<.+?>”
- asp.net如何去掉HTML标记
- asp.net如何去掉HTML标记
- asp.net如何去掉HTML标记
- asp.net如何去掉HTML标记
- asp.net如何去掉HTML标记
- asp.net如何去掉HTML标记
- asp.net去掉HTML标记
- Asp.net 去掉html中的标记.txt
- asp中去掉HTML标记
- asp如何去除html标记
- ASP.NET MVC @Html.DropDownList()如何去掉空白项
- js去掉HTML标记
- 去掉html标记
- C#去掉HTML标记
- ASP.NET 去除HTML标记 函数
- ASP.NET 去除所有HTML标记
- ASP.NET 清除 HTML 标记函数
- ASP.net中去除HTML标记
- Android Service 问题总结
- AlertDialog总是在最前,电话着信时着信画面被覆盖,如何解决
- linux多线程编程1--线程的创建
- java 设计模式之三-模版模式
- maximo库存
- asp.net如何去掉HTML标记
- android返回HOME界面
- x86中断向量表
- linux多线程编程2--属性的设置
- 用 DbUnit 执行 export 导出数据时报 MySQLSyntaxErrorException
- iOS annotation
- easyui datagrid行内编辑时的数据联动
- linux多线程编程3--mutex
- HTTP POST GET 本质区别详解