asp.net-mvc-3 – 删除Razor MVC 3中的HTML格式
发布时间:2020-12-16 04:02:58 所属栏目:asp.Net 来源:网络整理
导读:我正在使用MVC 3和Razor View引擎. 我想做什么 我正在使用MVC 3制作博客,我想删除所有HTML格式标签,例如 p LT b取代; I等等.. 我正在使用以下代码. (确实有效) @{ post.PostContent = post.PostContent.Replace("p"," "); post.PostContent = post.PostConte
我正在使用MVC 3和Razor View引擎.
我想做什么 我正在使用MVC 3制作博客,我想删除所有HTML格式标签,例如< p> < b取代; < I>等等.. 我正在使用以下代码. (确实有效) @{ post.PostContent = post.PostContent.Replace("<p>"," "); post.PostContent = post.PostContent.Replace("</p>"," "); post.PostContent = post.PostContent.Replace("<b>"," "); post.PostContent = post.PostContent.Replace("</b>"," "); post.PostContent = post.PostContent.Replace("<i>"," "); post.PostContent = post.PostContent.Replace("</i>"," "); } 我觉得必须有一个更好的方法来做到这一点.任何人都可以指导我这个. 解决方法
谢谢
Alex Yaroshevich,
这是我现在使用的.. post.PostContent = Regex.Replace(post.PostContent,@"<[^>]*>",String.Empty); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net-mvc – 更新实体框架MVC中的子实体
- 如何做一个ASP.NET MVC Ajax表单与multipart/form-data?
- asp.net-mvc – 高级ASP路由教程和示例
- asp.net-mvc – 多个模型和Breeze上下文的元数据问题
- ASP.net – Crystal Reports导出为PDF会将字母“i”随机添加
- 集训第六天:文件上传漏洞
- 让 .NET 轻松构建中间件模式代码
- asp.net-mvc-5 – 在MVC 5期货中找不到Html.Serialize助手
- asp.net – 随机字符串生成器在多个调用中创建相同的字符串
- asp.net – 使用实体框架选择所有行
推荐文章
站长推荐
- asp.net – Webservice方法返回XmlDocument,Refe
- asp.net – 仅为Web服务关闭customErrors
- asp.net-mvc-3 – 将数据从Action传递给另一个Ac
- asp.net-mvc – 发布ASP.NET MVC 3 Html.TextAre
- asp.net-mvc – MVC Razor RC 1:可以用字符串常
- 打造更好用的 EF 自动审计
- asp.net-mvc-4 – 如何将用户没有正确的角色重定
- asp.net 下载文件时根据MIME类型自动判断保存文件
- asp.net – 如何在成功插入数据后清除radiobutto
- asp.net-mvc – ASP.NET MVC – 动态授权
热点阅读