【问题标题】:How to prevent ckeditor not saving HTML tags, but just the rich text如何防止ckeditor不保存HTML标签,而只是富文本
【发布时间】:2017-08-03 09:14:08
【问题描述】:

请在附件中找到我的问题的 html 代码和打印屏幕。当我在 ckeditor 中编写内容并使用 html 标签应用样式时,它会使用 html 标签保存文本,而不仅仅是文本本身,在本例中只是 CONTENT SAMPLE TEXT,并将样式应用于html某些标签,并且不显示

结果:

  <div class="form-group">
        @Html.LabelFor(model => model.LongDescription1, htmlAttributes: new { @class = "control-label col-md-2" })
        <div class="col-md-10">

           @Html.TextAreaFor(model => model.LongDescription1, new { @id = "LongDescription1", @class = "form-control", @rows = "200" })



            @Html.ValidationMessageFor(model => model.LongDescription1, "", new { @class = "text-danger" })
            <script>CKEDITOR.replace("LongDescription1", { htmlEncodeOutput: true });</script>


        </div>
    </div>

【问题讨论】:

  • 我正在使用 Visual Studio 。

标签: html model-view-controller text ckeditor


【解决方案1】:

您的 HTML 代码已转义。您需要在显示之前取消转义它。

您可以使用 PHP 来做到这一点

$string = '&lt;div&gt;SAMPLE TEXT&lt;/div&gt;' ;
$string = html_entity_decode($string) ;
echo $string; 

输出

SAMPLE TEXT

在右侧的 div 中

【讨论】:

  • 谢谢,但这不是我想要的。我使用 asp.net mvc,它应该有一种方法可以自动转换富文本
猜你喜欢
  • 1970-01-01
  • 2014-03-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-05-17
  • 2020-05-14
  • 2016-03-22
  • 1970-01-01
相关资源
最近更新 更多