一、引入ckeditor到项目,将其config配置如下
/*
Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved.For licensing, see LICENSE.html or http://ckeditor.com/license
*/
CKEDITOR.editorConfig = function (config) {
config.filebrowserImageBrowseUrl = '../JavaScript/ckfinder/ckfinder.html?Type=Images';
config.filebrowserFlashBrowseUrl = '../JavaScript/ckfinder/ckfinder.html?Type=Flash';
config.filebrowserUploadUrl = '../JavaScript/ckfinder/core/connector/aspx/connector.aspx?command=QuickUpload&type=Files';
config.filebrowserImageUploadUrl = '../JavaScript/ckfinder/core/connector/aspx/connector.aspx?command=QuickUpload&type=Images';
config.filebrowserFlashUploadUrl = '../JavaScript/ckfinder/core/connector/aspx/connector.aspx?command=QuickUpload&type=Flash';
config.filebrowserWindowWidth = '800'; //“浏览服务器”弹出框的size设置
config.filebrowserWindowHeight = '500';
// Define changes to default configuration here. For example:
// config.language = 'fr';
// config.uiColor = '#AADC6E';
//定义语言,此处改为中文
config.language = 'zh-cn'; //中文
//字体
config.font_names = '宋体;楷体;新宋体;黑体;隶书;幼圆;微软雅黑;Arial;Comic Sans MS;Courier New;Tahoma;Times New Roman;Verdana';
//默认使用的toolbar(工具栏),此设定名字为“Basic”的toolbar为系统默认的工具栏
config.toolbar = 'Full';
config.toolbar_Full =
[
/*{ name: 'document', items: ['Source', 'Save', 'Preview'] },
{ name: 'clipboard', items: ['Cut', 'Copy', 'Paste', '-', 'Undo', 'Redo'] },
{ name: 'editing', items: ['SelectAll'] },
{ name: 'forms', items: ['Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton'] },
{ name: 'basicstyles', items: ['Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat'] },
{ name: 'paragraph', items: ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote', 'CreateDiv', '-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock', '-', 'BidiLtr', 'BidiRtl'] },
{ name: 'links', items: ['Link', 'Unlink'] },
{ name: 'insert', items: ['Image', 'Table', 'HorizontalRule', 'Smiley', 'SpecialChar'] },
{ name: 'styles', items: ['Styles', 'Format', 'Font', 'FontSize'] },
{ name: 'colors', items: ['TextColor', 'BGColor'] },
{ name: 'tools', items: ['Maximize', 'ShowBlocks'] }*/
{name: 'document1', items: ['Source'] },
{ name: 'document3', items: ['Preview'] },
{ name: 'document4', items: ['Undo', 'Redo'] },
{ name: 'document5', items: ['Font'] },
{ name: 'document6', items: ['FontSize'] },
{ name: 'document7', items: ['TextColor'] },
{ name: 'document8', items: ['BGColor'] },
{ name: 'document11', items: ['Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat'] },
{ name: 'document12', items: ['Outdent', 'Indent'] },
{ name: 'document14', items: ['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'] },
{ name: 'document15', items: ['Link', 'Unlink'] },
{ name: 'document16', items: ['Image', 'Table'] },
{ name: 'document17', items: ['HorizontalRule', 'Smiley', 'SpecialChar'] },
{ name: 'document9', items: ['Maximize', 'ShowBlocks'] }
];
config.filebrowserUploadUrl = "actions/ckeditorUpload";
var pathName = window.document.location.pathname;
//获取带"/"的项目名,如:/uimcardprj
var projectName = pathName.substring(0, pathName.substr(1).indexOf('/') + 1);
config.filebrowserImageUploadUrl = projectName + '/system/upload.do'; //固定路径
};
二、引入ckfinder到项目,修改其config.ascx
public override bool CheckAuthentication()
{
// WARNING : DO NOT simply return "true". By doing so, you are allowing
// "anyone" to upload and list the files in your server. You must implement
// some kind of session validation here. Even something very simple as...
//
// return ( Session[ "IsAuthorized" ] != null && (bool)Session[ "IsAuthorized" ] == true );
//
// ... where Session[ "IsAuthorized" ] is set to "true" as soon as the
// user logs on your system.
return true;//修改为true,原为false
}
三、在引入的页面引入
<textarea id="Edit_Article_content" rows="30" cols="40" class="ckeditor" name="name_Edit_Article_content"></textarea>
四、如何获取和设置文本框内容
var text = CKEDITOR.instances.Edit_Article_content.getData();
var theData = node.Centent;
CKEDITOR.instances.Edit_Article_content.setData(theData);