删除块 html 标签。 TinyMCE
Removing block html tags. TinyMCE
我已将 TinyMCE 添加到我的项目中。我已经设置了文本样式并将其值发送到数据库。然后我希望它显示在视图中。但它显示在 HTML 标签中。我怎样才能摆脱 HTML 标签?
Js:
<script>
tinymce.init({
selector: '#Content',
height: 500,
theme: 'modern',
plugins: [
'advlist autolink lists link image charmap print preview hr anchor pagebreak',
'searchreplace wordcount visualblocks visualchars code fullscreen',
'insertdatetime media nonbreaking save table contextmenu directionality',
'emoticons template paste textcolor colorpicker textpattern imagetools'
],
forecolor: { inline: 'span', classes: 'forecolor', styles: { color: '%value' } },
hilitecolor: { inline: 'span', classes: 'hilitecolor', styles: { backgroundColor: '%value' } },
custom_format: { block: 'h1', attributes: { title: 'Header' }, styles: { color: 'red' } },
toolbar1: 'insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image',
toolbar2: 'print preview media | forecolor backcolor emoticons ',
image_advtab: true,
});
</script>
查看:
@foreach (Blog blog in Model.Blog)
{
@blog.posttext
}
posttext
显示为:<p><span style="color: #008080; background-color: #33cccc;">hi</span></p>
最后,我通过禁用HTML编码解决了这个问题:
@Html.Raw(HttpUtility.HtmlDecode(blog.posttext))
我已将 TinyMCE 添加到我的项目中。我已经设置了文本样式并将其值发送到数据库。然后我希望它显示在视图中。但它显示在 HTML 标签中。我怎样才能摆脱 HTML 标签?
Js:
<script>
tinymce.init({
selector: '#Content',
height: 500,
theme: 'modern',
plugins: [
'advlist autolink lists link image charmap print preview hr anchor pagebreak',
'searchreplace wordcount visualblocks visualchars code fullscreen',
'insertdatetime media nonbreaking save table contextmenu directionality',
'emoticons template paste textcolor colorpicker textpattern imagetools'
],
forecolor: { inline: 'span', classes: 'forecolor', styles: { color: '%value' } },
hilitecolor: { inline: 'span', classes: 'hilitecolor', styles: { backgroundColor: '%value' } },
custom_format: { block: 'h1', attributes: { title: 'Header' }, styles: { color: 'red' } },
toolbar1: 'insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image',
toolbar2: 'print preview media | forecolor backcolor emoticons ',
image_advtab: true,
});
</script>
查看:
@foreach (Blog blog in Model.Blog)
{
@blog.posttext
}
posttext
显示为:<p><span style="color: #008080; background-color: #33cccc;">hi</span></p>
最后,我通过禁用HTML编码解决了这个问题:
@Html.Raw(HttpUtility.HtmlDecode(blog.posttext))