Use CKEditor and CKFinder configuration in ASP. NET, ckeditorckfinder
Include CKEditor and CKFinder in the project and add reference to the Assembly.
Download the CKEditor and CKFinder from the http://cksource.com website, and extract the two under the project, the samples FOLDER inside is an example, is not needed to directly Delete the samples folder, the ckeditor and ckfinder directories have their own bin directories. Add references to the Assembly under the release directory under the bin directory.
2. register the user control on the page that requires the rich text editor.
Copy codeThe Code is as follows:
<% @ Register Assembly = "CKEditor. NET" Namespace = "CKEditor. NET" TagPrefix = "CKEditor" %>
3. Use CKEditor
Add a Rich Text Editor, just like using your own user controls, using CKEditor
Copy codeThe Code is as follows:
<CKEditor: CKEditorControl Height = "400" runat = "server" ID = "txtNewsContent"> </CKEditor: CKEditorControl>
1. Integrate CKFinder
Rewrite the OnLoad method of the Page in the corresponding Page code Page, and integrate CKFinder into CKEditor In the OnLoad method.
Copy codeThe Code is as follows:
Protected override void OnLoad (EventArgs e)
{
CKFinder. FileBrowser browser = new CKFinder. FileBrowser ();
// Integrate it into the corresponding CKEditor. The parameter is the corresponding id.
Browser. SetupCKEditor (txtNewsContent );
// Set the directory for storing uploaded files
Browser. BasePath = "~ /Files /";
Base. OnLoad (e );
}
2. Configure CKFinder
Ckfinder is a tool for refreshing uploads. For upload, strict permission control is required, mainly in two aspects: first, no one can upload, only authorized persons can upload files. Second, no files can be uploaded. To control uploaded files, users cannot upload executable files to the server, you need to control the file type.
Open config in the ckfinder directory. ascx, the first method is to verify authorization. to check whether the user has the permission to upload files, you can verify the session to verify whether the user is authorized. The default value is return false. If no modification is added, an error is reported when uploading data directly. If you are not authorized to upload the data, you can change it to return true in the test phase. If you publish the data, you are advised to verify the permission, do not directly return true (here I will verify whether the user has logged on. If you log on, return true; otherwise, return false)
As shown in the following figure, the SetConfig () method sets some configuration items for file uploading, such as the path for saving the uploaded file and the restrictions on the file type, to set a style, modify config. js files
The above is all the content of this article. I hope you will like it.