在 ASP.NET MVC 中使用 CKEditor 的问题
我使用CKEditor在不同的视图中输入富文本描述。我的 ckeditor 标签看起来像
<ckeditor:ckeditorcontrol id="CKEditor1" runat="server" toolbar="Basic" />
让我记下我面临的问题:
- 尽管我的工具栏很基本,但我正在为编辑器获取完整的选项工具栏。
- 在编辑视图中,描述将作为其文本出现在 ckeditor 中。这怎么办呢。指令名称的文本框为
<%=Html.TextBoxFor(m => m.InstructionName, new { @class="formstyle"} )%>
,其中显示编辑中的指令名称看法。效果很好。我想要与InstructionDesc 相同的功能,它是一个ckeditor。
我尝试过,
<CKEditor:CKEditorControl ID="CKEditor1" runat="server" Toolbar="Basic" name="docDesc" Text=<%=Model.DocDesc %> />
但这引发了错误:
解析服务此请求所需的资源时发生错误。请查看以下具体解析错误详细信息并适当修改您的源文件。
解析器错误消息:服务器标记不能包含 <% ... %>
结构。
请帮我解决这些问题。提前致谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可能需要不再使用 asp.net 样式控件,而是手动或通过 HTML 帮助程序创建文本区域。我们在母版页的头部导入 CKEditor javascript,然后在使用 CKEditor 时在视图中导入以下内容:
这应该将文本区域转换为 CKEditor 实例。替换中的名称需要与文本区域的 ID 匹配。
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:
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.
您确定该控件可以与 ASP.NET MVC 一起使用吗?
are you sure this control can be used with ASP.NET MVC?