删除html块标签。TinyMCE

问题描述 投票:0回答:1

我在项目中加入了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>

c# html asp.net-mvc tinymce
1个回答
1
投票

最后,我通过禁用HTML编码解决了这个问题。

@Html.Raw(HttpUtility.HtmlDecode(blog.posttext))
© www.soinside.com 2019 - 2024. All rights reserved.