Question

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:

  • Even though my toolbar is basic am getting full option toolbar for editor.
  • In edit view the description is to be there in the ckeditor as its text. How can this be done. The textbox for Instruction name is given as <%=Html.TextBoxFor(m => m.InstructionName, new { @class="formstyle"} )%> which shows the InstructionName in edit view. Which works fine. I want the same with InstructionDesc which is a ckeditor.

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.

Was it helpful?

Solution

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.

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top