Suja Shyam
Suja Shyam

Reputation: 971

Issues with using CKEditor in ASP.NET MVC

I use CKEditor to enter rich text descriptions in different views. My ckeditor tags looks like

<ckeditor:ckeditorcontrol id="CKEditor1" runat="server" toolbar="Basic" />

Let me note down the issues am facing:

I tried

<CKEditor:CKEditorControl ID="CKEditor1" runat="server" Toolbar="Basic" name="docDesc" Text=<%=Model.DocDesc %> />

but this is throwing error:

An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: Server tags cannot contain <% ... %> constructs.

Please help me solve these issues. Thanks in advance.

Upvotes: 0

Views: 1835

Answers (2)

AndyM
AndyM

Reputation: 1200

You'll probably need to move away from using the asp.net style control and create a text area either manually or through an HTML helper. We import the CKEditor javascript in the head of our master page and then the following in the view when CKEditor is used:

<%= Html.TextAreaFor(m=>m.InstructionDesc) %>
<script type="text/javascript">CKEDITOR.replace('InstructionDesc');</script>

That should convert the text area into a CKEditor instance. The name inside the replace will need to match the ID of the text area.

Upvotes: 4

Andrey
Andrey

Reputation: 6184

are you sure this control can be used with ASP.NET MVC?

Upvotes: 0

Related Questions