1

イントラネットでckeditorを使用しています。たとえば、リンクなどのフォーマットされたテキストを保存するために使用します。

問題は、私がckeditorソースに持っているのは

<p>
this is the new <a href="http://www.google.com">test</a> we need to run.</p>

エディターに表示されるのは

test(as a link)

DBに保存されるのは

 &lt;p&gt;
    this is the new &lt;a href="http://www.google.com"&gt;test&lt;/a&gt; we need to run.&lt;/p&gt;

どちらが正しい。

しかし、ckeditorで編集したい場合、私が見るのは

<p> <a href="http://www.google.com">test</a></p>

そして私がソースとして見ているのは

&lt;p&gt;
        &lt;a href="http://www.google.com"&gt;test&lt;/a&gt;&lt;/p&gt;

編集するときもまったく同じように見たいです。

特筆すべきは、Html.Rawを使用してインデックスに表示しているのですが、htmlが表示されています。レンダリングされたhtmlを見たいのですが。

だから、私が保存すると

<p>
    this is the new <a href="http://www.google.com">test</a> we need to run.</p>

見たい

this is the new test(as link) we need to run

ではなく

<p>
        this is the new <a href="http://www.google.com">test</a> we need to run.</p>

何か案は??ルイ・マーティンズ

4

2 に答える 2

0

あなたの問題は、htmlentitiesを理解していないことです。

HTMLのエンコード

http://php.net/manual/en/function.htmlentities.php

HTMLのデコード

http://www.php.net/manual/en/function.html-entity-decode.php

両方の使用例

<?php

   $orig = "I'll \"walk\" the <b>dog</b> now";

   $a = htmlentities($orig);
   $b = html_entity_decode($a);

   echo $a; // I'll &quot;walk&quot; the &lt;b&gt;dog&lt;/b&gt; now
   echo $b; // I'll "walk" the <b>dog</b> now

?>

編集(同等のasp.netを追加)

Server.HtmlEncode("<your string>");

Server.HtmlDecode("&lt;your string&gt;");
于 2012-11-13T15:48:17.000 に答える
0

このコードを試してください:

<%: Html.Raw(HttpUtility.HtmlDecode(YourHTMLStringHere)) %>

HTMLコードをレンダリングするだけです

于 2015-02-03T08:19:21.483 に答える