CKEditor MVC 3 implementation

守給你的承諾、 提交于 2019-12-01 06:03:07

You aren't actually using the CKEditor helper at all like is described on that blog page (which is my own blog)

The purpose of that helper is that once you have included the code correctly into your project, you can simply do this:

@Html.CKEditorFor(model=>model.Description)

However, you seem to simply be creating a plain-old text area and working with it 'manually' after that. There isn't anything to bind it to your property, as would exist if you had used the helper described in that post.

Also note that you aren't using the code that Updates the text area behind the scenes; so if your model has Required set on the Description field, you will get a client-side validation error the first time you submit an otherwise properly-configured CKEditorFor() This isn't unique to my helper; any bound property that is 'required' needs the bit of Javascript that is mentioned in that blog post, too. I do it as an onclick off the submit button, but you can run that same code anywhere. You just need to include it in the page, which you haven't done.

You might want to try setting the name attribute of the textarea to "Description"

so:

<div class="editor-field">            
    <textarea class="ckeditor" id="ckeditor" rows="10" name="Description"></textarea>
</div>

if that doesn't work then you might have to use javascript to get the value of what's in the editor and set it in a hidden field before the post.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!