A.Mano
A.Mano

Reputation: 291

Integrate CKEditor to a blog's razor view Create.cshtml editor-field

For a blog mvc 3 app. I have already the CRUD functionality and for Creating the content of a post I want to use CKEditor. So:

For Create.cshtml View I have

  <div class="editor-field">
    @Html.EditorFor(model => model.Content )
    @Html.ValidationMessageFor(model => model.Content)
    </div>

Now, CKEditor works fine for simple textarea> elements and a submit button.For example:

textarea class="ckeditor" id="editor1" rows="10" cols="20">Sample Text</textarea>
               <input type="submit" name="submit" value="Submit" />

My question is how to associate it with the model property in a view so instead of simple multiline textbox it will show CKEditor. Thanks in advance!

Upvotes: 0

Views: 2324

Answers (1)

Andy
Andy

Reputation: 11

Ok, is as simple as this:

   <div class="editor-field">
        @Html.TextAreaFor(model => model.Text, new { @class = "ckeditor", rows = "15", columns = "130" })
        @Html.ValidationMessageFor(model => model.Text)
    </div>

Upvotes: 1

Related Questions