asp.net mvc - Trouble with CKEditor when displaying output -
i'm using ckeditor along asp.net mvc
, there's strange problem : if format text (e.g. apply boldness, make italic, or make list) when there's error , content must post textarea, displayed html text - "ul li " , on instead of being styled again (bold, italic , on).
i've applied options in config:
config.htmlencodeoutput = true; // avoid text being interpreted attack config.entermode = ckeditor.enter_br; // in order not place tags arround text config.basicentities = false; // display spaces instead of , on...
i tried built in functions in mvc
server.htmldecode
, httputility.decode
nothing seems work. solutions other editors work fine mvc
accepted.
here .cshmtl file:
@{ 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" /> }
in action method nothing return data again testing purposes:
[httppost] public actionresult index(simplemodel model) { //model.text = server.htmldecode(model.text); return view(model); }
the simplemodel class test model class 1 property - text.
you can try this
@foreach (var item in model) { <tr> <td> @html.displayfor(modelitem => item.title) </td> <td> @{ string description = server.htmldecode(item.description); } @html.raw(description) </td> <td> @html.displayfor(modelitem => item.note) </td> <td> <img src="~/img/uploads/@item.pic" width="150" height="120" /> </td> </tr> }
Comments
Post a Comment