This is what the output textarea looks like when you use the TinyMCE editor in MVC3 application
Step 1: Download the tinymce jquery version from http://www.tinymce.com/ and add the scripts to the required folder.
Step 2: Add the below scripts to the view where you want to display the word editor. Also make sure that the scripts in tiny_mce are also included to the solution.
<script type=”text/javascript” src=”@Url.Content(“~/Scripts/tinymce/jquery.tinymce.js”)”></script>
<script type=”text/javascript” src=”@Url.Content(“~/Scripts/tinymce/tiny_mce.js”)”></script>
<script type=”text/javascript”>
tinyMCE.init({
mode:“textareas”,
theme :“advanced”,
plugins :“autolink,lists,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,advlist”,
theme_advanced_buttons1 :“save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect”,
theme_advanced_buttons2 :“cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor”,
theme_advanced_buttons3 :“tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen”,
theme_advanced_buttons4 :“insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak”,
theme_advanced_toolbar_location :“top”,
theme_advanced_toolbar_align :“left”,
theme_advanced_statusbar_location :“bottom”,
theme_advanced_resizing :true,
});
</script>
Step3: Now use @Html.TextAreaFor(model => model.TextDescription, new { cols=“85”, rows=“8”})
in the view to display and return formatted text to the controller.
Step4: Make sure that the action has [ValidateInput(false)] attribute added to it. Just in case, the model has <p> or other content that might be red flagged.