ckeditor - Why can't I HtmlDecode in ASP.NET MVC 3 -


here scenario. want use ckeditor rich text field on form, whatever reason cannot contents textarea server , page without encoding problems. here little sample program wrote try , figure out going on. first, view model:

homeviewmodel.cs

namespace ckeditortest.models {     public class homeviewmodel     {         [required]         [datatype(datatype.html)]         [display(name = "note")]         public string note { get; set; }     } } 

now controller:

homecontroller.cs

using system.web.mvc; using ckeditortest.models;  namespace ckeditortest.controllers {     public class homecontroller : controller     {         public actionresult index()         {             return view(new homeviewmodel());         }          [httppost]         [validateinput(false)]         public actionresult index(homeviewmodel model)         {             return view(model);         }     } } 

and finally, view:

index.cshtml

@model ckeditortest.models.homeviewmodel @{     viewbag.title = "ckeditor test"; } @section head {     <script type="text/javascript" src="@url.content("~/scripts/ckeditor/ckeditor.js")"></script>     <script type="text/javascript" src="@url.content("~/scripts/ckeditor/adapters/jquery.js")"></script>      <script type="text/javascript">         $(document).ready(function () {             $("#note").ckeditor();         });     </script> }  <h2>ckeditor test</h2>  @using (html.beginform()) {     @html.labelfor(m => m.note)<br /><br />     @html.textareafor(m => m.note)<br />     <input type="submit" /> }  @if (!string.isnullorempty(model.note)) { <div id="notetext">@model.note</div> } 

no matter do, cannot display model.note property html on view. time reaches view html encoded (i.e. <p> etc...). here form looks pre-post:

pre-post http://www.matthewkimber.com/images/so/pre-post.png

and here result in div below "submit" button:

post result http://www.matthewkimber.com/images/so/posted.png

i've set breakpoint within visual studio , shows bare angle brackets (no encoding on html elements, characters).

breakpoint results http://www.matthewkimber.com/images/so/datainsidetheactionmethod.png

this, of course, stripped down test. i've tried encoding it, decoding both in view , in controller no avail. appreciated! thanks!

by default encoded when use razor. think you're looking raw method.

it idea check response using fiddler or firebug.


Comments

Popular posts from this blog

razor - Is this a bug in WebMatrix PageData? -

c# - How to set Z index when using WPF DrawingContext? -