user1677467
user1677467

Reputation: 5

Unable to get ckEditor in partailview

Am working on asp.net MVC3. I need to use ckeditor in a partail view.

IN Controller:

public PartialViewResult Compose()
        {
            return PartialView();
        }

and my view contains

<% using (Html.BeginForm()) { %>

 <%: Html.TextArea("Body", signature , new { @class = "ckeditor", rows = "5", cols = "15"})%> 

<% } %>

Upvotes: 0

Views: 249

Answers (1)

card_master
card_master

Reputation: 418

I am using ASP.NET MVC 3, the concept should be the same

First import all the library to the root folder of your project otherwise some dependencies for file will be missing

Include this js file to your view

<script type="text/javascript" src="@Url.Content("~/ckeditor.js")"></script>

In Your controller do the following

public PartialViewResult Compose(){
    return PartialView("CKeditor");
}

In Your view load the partial view with the script

@using (Html.BeginForm()){
     @Html.TextArea("body", new { @id = "editor1", name = "editor1", rows = "30", cols = "100" })
}

<script type="text/javascript">
     CKEDITOR.replace('editor1');
</script>

Download the Source Code

Upvotes: 1

Related Questions