views:

228

answers:

1

Hello, Does anyone know how to auto-populate the tinymce editor from the ASP.NET MVC model? In other words, what code do I need to use to set the contents of tinymce?

EDITED:

My problem is that tinyMCE is hiding my textbox contents. It opens blank, even though if I view the source of the page in my browser, it shows the correct info (i.e. from the Model).

Here is my code:

Javascript:

<script type="text/javascript">
    tinyMCE.init({
        theme: "advanced",
        mode: "textareas",
        plugins: "",
        theme_advanced_buttons3_add: "fullpage",
        theme_advanced_toolbar_location: "top"
      }

    );
</script>

Text Area:

<%= Html.TextArea("PostContent", Model.PostContent,30, 68, new {id="newPost"}) %>

Thanks, Jack

+1  A: 
<textarea><%= Model.TextAreaContent %></textarea>

Please note that since you cannot escape the contents of your string (you need proper HTML elements for TinyMCE) you have to be sure that there's nothing nasty within your string. I'm using the HTML Agility Pack to prefilter the contents before putting it into the page.

DrJokepu
That did it. Thanks!
jchapa