と一緒に CKEditor を使用してASP.NET MVC
いますが、非常に奇妙な問題があります。エラーが発生し、コンテンツをテキストエリアにポストバックする必要があるときにテキストをフォーマットすると (太字にする、イタリックにする、リストにするなど)、 HTML テキスト (太字、イタリック体など) ではなく、"ul li" などのように表示されます。
config にいくつかのオプションを適用しました。
config.htmlEncodeOutput = true; // to avoid text being interpreted as attack
config.enterMode = CKEDITOR.ENTER_BR; // in order not to place tags arround the text
config.basicEntities = false; // do display spaces as they are instead of and so on...
MVC
likeでいくつかの組み込み関数を試しましたが、何も機能しServer.HtmlDecode
てHttpUtility.Decode
いないようです。正常に動作する他のエディターを使用したソリューションMVC
も受け入れられます。
.cshmtl ファイルは次のとおりです。
@{
ViewBag.Title = "CkEditor";
}
@model HtmlTextEditorsDemos.Models.SimpleModel
<h2>CkEditor</h2>
<script src="~/Scripts/ckeditor.js"></script>
@using (Html.BeginForm())
{
@Html.TextAreaFor(x => x.Text, new { @class = "ckeditor" })
<input type="submit" value="send" />
}
アクション メソッドでは、テスト目的でデータを再度返す以外は何もしません。
[HttpPost]
public ActionResult Index(SimpleModel model)
{
//model.Text = Server.HtmlDecode(model.Text);
return View(model);
}
SimpleModel クラスは、1 つのプロパティ (Text) のみを持つ単なるテスト モデル クラスです。