jQuery 如何将 CKEditor 集成到 Asp.net MVC 中

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1856350/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 12:16:35  来源:igfitidea点击:

How to integrate CKEditor into Asp.net MVC

jqueryasp.net-mvcckeditorfckeditor

提问by gkdm

Saw this postat CodeProject for FCKEditor. Can someone explain what about the new version?

在 FCKEditor 的 CodeProject 上看到了这篇文章。有人可以解释一下新版本的情况吗?

回答by ryanulit

It's pretty easy to do actually. First download the latest code from the websiteand extract it to a directory in your project (I choose /Scripts/ckeditor). Then in your view, use the same code as in the "complete sample" in this linkand it should work.

实际上很容易做到。首先从网站下载最新的代码并解压到你项目中的一个目录中(我选择/Scripts/ckeditor)。然后在您看来,使用与此链接中“完整示例”相同的代码,它应该可以工作。

Basically, the important steps are:

基本上,重要的步骤是:

  1. Make sure you include the ckeditor.js file in the head from your view or in your master page, however you want to do it. This needs to be the exact location within your project (I would use the find file dialog that you can popup when editing a src attribute in visual studio so that it automatically links to the file).
  2. Place the:

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

    RIGHT AFTER your textarea and make sure the id of the textarea is the same in the CKEDITOR.replace() statement.

  1. 确保您在视图的头部或母版页中包含 ckeditor.js 文件,无论您想怎么做。这需要是您项目中的确切位置(我将使用在 Visual Studio 中编辑 src 属性时可以弹出的查找文件对话框,以便它自动链接到文件)。
  2. 放置:

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

    在你的 textarea 之后,并确保 textarea 的 id 在 CKEDITOR.replace() 语句中是相同的。

回答by DeepakJ

In MVC, you can not use CKEDITOR.DLL and its tags to, So you need to use ckeditor.js file.

在MVC中,你不能使用CKEDITOR.DLL及其标签,所以你需要使用ckeditor.js文件。

Steps to use CKeditor in MVC3.

在 MVC3 中使用 CKeditor 的步骤。

  1. Include the ckeditor.js file to the razor page.
  2. And then put CKEDITOR.replace( 'textAreaId' );
  1. 将 ckeditor.js 文件包含到 razor 页面。
  2. 然后把 CKEDITOR.replace( 'textAreaId' );