A recent project has a news module that requires a rich text editor that supports ASP.net, and requires images to be uploaded locally.
To find the Internet, there are a lot of simple JS Rich Text editor, however, when you insert a picture, you need to provide the path of the network picture, which requires that the picture to be used is uploaded to a support album, which is clearly unacceptable to the customer, and later, from the blog of the Netizen, found the CKEditor ( Dot I browse the official website demo), research, found that it is configured well after ckfind, to meet my needs, after some configuration and debugging, the environment, I took the detour out of it, sorted out a simple configuration process and demo.
"First step: Download CKEditor and Ckfinder"
Resources are of course in the official website to download the most reassuring, official website address is: CKEditor (click to open)
The first thing to understand:
CKEditor like other rich text editors, inserting pictures and Flash also requires a network path, and uploading local images is a ckfind feature , so you have to configure both, otherwise, there's not much difference between the other rich text editors you're looking for.
Where to download CKEditor and Ckfind.
Click to enter the official website: http://ckeditor.com/
Click on the download link to find the latest version of CKEditor, and note the download of ckeditor for asp.net:
Download is a ZIP package.
Then download the Ckfind package: Ckfinder official website, pay attention to download the asp.net version.
After the download, you will get the ckeditor_aspnet_3.6.1 and Ckfind compression package.
"Step Two: Configure CKEditor"
Unzip the CKEditor package downloaded in the first step, and you will get the following structure directory:
Open the _samples folder, which contains all the files required for the configuration, and follow these steps to complete the CKEditor configuration:
1. Add a reference: Open the _samples\bin directory, find the CKEditor.NET.dll, copy to your project (preferably in the site root directory to create a special folder for Third-party dynamic link library files), and then add a reference.
2. copy ckeditor:_samples contains a folder called CKEditor, which is a rich text editor of some styles, JS and interface package, need to copy to your project, before the introduction of the project, you can do the appropriate streamlining:
If you do not need to support languages other than Chinese and English, you can delete all JS files in the Lang folder except En and en. There are three kinds of skin, according to the preference, can delete the other two, under the Skins folder (of course you need to be configured, look at three different skin effects, and then make a decision). Changes.html, install.html, license.html in the root directory can be deleted.
3. Configure the Rich Text Editor function: find the Config.js under the CKEditor folder, do some configuration according to the following:
/* Copyright (c) 2003-2011, Cksource-frederico Knabben.
All rights reserved. For licensing, license.html or http://ckeditor.com/license/ckeditor.editorconfig = function (config) {config. Skin = ' kama '//kama,v2,office2003, skin setting Config.language = ' ZH-CN '; Set the Chinese environment config.font_names = ' XXFarEastFont-Arial _gb2312; new XXFarEastFont-Arial; bold; XXFarEastFont-Arial; Microsoft James Black; Arial; Comic Sans MS; Courier New; Tahoma; Times New Roman; Verdana '; Edit font settings Config.toolbar = [[' Source ', '-', ' Preview '], [' Cut ', ' Copy ', ' Paste ', ' pastetext ', ' Pastefromwo Rd '], [' Undo ', ' Redo ', '-', ' find ', ' Replace ', '-', ' selectall ', ' Removeformat '], [' Bold ', ' Italic ', ' unde Rline ', ' Strike ', '-', ' subscript ', ' superscript ', [' justifyleft ', ' justifycenter ', ' justifyright ', ' Justifyblock '], [' Link ', ' Unlink ', ' Anchor '], [' Image ', ' Flash ', ' Table ', ' horizontalrule ', ' Specialchar ', ' Styles ', '
Format ', ' Font ', ' fontsize '], [' TextColor ', ' bgcolor '], [' Maximize ', '-', ' about ']];
//Set Reference Path Config.filebrowserbrowseurl = '..
/ckfinder/ckfinder.html '; Config.filebrowserimagebrowseurl = '.. /ckfinder/ckfinder.html?
Type=images '; Config.filebrowserflashbrowseurl = '.. /ckfinder/ckfinder.html?
Type=flash '; Config.filebrowseruploadurl = '..
/ckfinder/core/connector/aspx/connector.aspx?command=quickupload&type=files '; Config.filebrowserimageuploadurl = '..
/ckfinder/core/connector/aspx/connector.aspx?command=quickupload&type=images '; Config.filebrowserflashuploadurl = '..
/ckfinder/core/connector/aspx/connector.aspx?command=quickupload&type=flash ';
};
There are two built-in settings for toolbar:
Config.toolbar = "Basic";
Config.toolbar = "full";
As the name implies, one is the most basic button, one is to include all the function buttons.
In addition, you can customize the configuration, unwanted buttons can be replaced with '-' (note: [] the elements in [] are not fixed, you can put the key in a [] in the other [], so modified, the Editor function button in the position of the distribution of different.
The set reference path is configured for Ckfinder, and must be set according to where CKEditor and Ckfinder are placed.
" Step Three: Configure Ckfinder"
After downloading to the ZIP package, extract the following files:
Ckfinder\bin\release\ directory to find CKFinder.dll, copy to your site, and add references.
Copy the entire Ckfinder folder to your site, note that in the second step, there is a configuration for the Ckfinder location, where Ckfinder is kept in line with that configuration.
At this point, the configuration of CKEditor and Ckfinder is basically OK, and then how to use CKEditor in the page.
" Step Fourth: How to use CKEditor"
First, in the page where you want to use the Rich Text editor, add type registration:
<% @Register assembly= "ckeditor.net" namespace= "ckeditor.net" tagprefix= "CKEditor"%>
Next, introduce two JS files:
<script type= "Text/javascript" language= JavaScript "src=". /ckfinder/ckfinder.js "></script>
<script type=" Text/javascript "language=" JavaScript "src=". /ckeditor/ckeditor.js "></script>
Note the path.
Then, add the control:
<ckeditor:ckeditorcontrol id= "CKEditor1" width= "#999999" uicolor= "200px" height= "Server" runat= Ckeditor:ckeditorcontrol>
In this way, you can directly manipulate the CKEditor1 object in the background, the text attribute inside that is the data you want.
" problems encountered while configuring "
Encountered a few problems, no screenshots, there is no way to describe more detailed, but I can list a few prone to errors in the place:
1. Added a ckeditor reference, but did not copy the CKEditor folder, resulting in the page to add controls in, the display is a textarea.
2. Without adding a ckfinder reference, it will cause an error in uploading the file, and Ckfinder will display the error message as a Web page in the text box of the uploaded file, making it difficult to find the error message.
3. In the config.js of CKEditor, the Ckfinder path configuration error will result in the inability to see the uploaded label page and not upload the local picture.
Summary: Overall, the configuration is not complex, things easy to use, easy to use, and finally attached a few other written more clear CKEditor related configuration of the blog:
Configure CKEditor and Ckfinder in asp.net
CKEditor and Ckfinder localization transformation in China