Use ckeditor and ckfinder in Asp.net

Source: Internet
Author: User
1. Download ckeditor_3.0.1.zip and decompress it to ckeditor (in the root directory ).

Official Website:Ckeditor(Fully functional, open source Editor, with source code encoded)

 

:Ckeditor

2. Load ckeditor. js on the aspx page or master template page

<! -- Load the ckeditor JS file -->
<SCRIPT src = "../ckeditor. js" type = "text/JavaScript"> </SCRIPT>

Use ckeditor in the <body> label:

<! -- To use ckeditor, you must define class = "ckeditor" -->
<Asp: textbox id = "txtcontent" class = "ckeditor" textmode = "multiline" text = '<% # BIND ("info ") %> 'runat = "server"> </ASP: textbox>

Similar to other. Net controls, setting text = '<% # BIND ("info") %>' facilitates interaction with data sources.

3. Custom config. js

/*
Copyright (c) 2003-2009, cksource-Frederico knabben. All rights reserved.
For licensing, see license.html or
Http://ckeditor.com/license
*/

Ckeditor. editorconfig = function (config ){

// Define changes to default configuration here. For example:
Config. Language = 'zh-cn'; // configuration language
// Config. uicolor = '# fff'; // background color
// Config. width = 400; // width
Config. Height = 400; // height
Config. Skin = 'v2'; // editor Style

// Cancel the "drag to change the size" Function
Config. resize_enabled = false;

// basic toolbar
// config. toolbar = "Basic";
// All-Around toolbar
// config. toolbar = "full";
// custom toolbar
config. toolbar =
[
['source', '-', 'preview'], ['cut ', 'copy', 'paste', 'pastetext ', 'pastefromword'], ['undo ', 'redo', '-', 'Find ', 'replace', '-', 'selectall', 'removeformat'], ['numberlist', 'bulletedlist', '-', 'outdent ', 'indent', 'blockquote', 'showblocks '],'/',
['bold ', 'italic', 'underline', 'strike', '-', 'subscript', 'superscript'], ['justifyleft ', 'justifycenter', 'justifyright', 'justifyblock'], ['link', 'unlink', 'anchor '], ['image', 'flash', 'table ', 'horizontalrule', 'specialchar '],'/',
['styles', 'format', 'font', 'fontsize'], ['textcolor ', 'bgcolor'], ['maximize', '-', 'about']
];

};

4, to streamline ckeditor can be _ samples, _ source folder Delete, Lang directory can only retain en. JS, Zh. JS, zh-cn.js three language files.

5. ckeditor does not provide the upload function. ckfinder must be integrated to implement the upload function.

How to configure ckfinder and ckeditor integration:

Official Website: ckfinder (powerful and easy to use Ajax File Manager for Web browsers)

:Ckfinder for Asp.net

6. Download ckfinder_aspnet_1.4.1.1.zip and decompress it to ckfinder (in the root directory ).

7. Cut "\ ckfinder \ bin \ ckfinder. dll" to the bin folder in the root directory or add ckfinder. dll references. Otherwise, the following error occurs:

XML request error: internal server error (500)

Do you want to see more info?

8. Open "\ ckfinder \ config. ascx" and change the baseurl to baseurl = "~ /Ckfinder/userfiles /";
// Note "~"
// Use userfiles as the default path. subdirectories such as images and Flash are automatically generated under the directory.

9. Integrate ckfinder in ckeditor/config. js.

// Customize the ckeditor Style
Ckeditor. editorconfig = function (config ){
......
}

// Integrate ckfinder in ckeditor. Make sure that the ckfinder path is selected correctly.
Ckfinder. setupckeditor (null, '../ckfinder /');

10. Crack the comment of [This is the demo version of ckfinder. Click here to visit our web site:

11. Load ckfinder. js on the aspx page or master template page

<! -- Load the ckfinder JS file -->
<SCRIPT src = "../ckfinder. js" type = "text/JavaScript"> </SCRIPT>

Use ckfinder in the <body> label:

<! -- To use ckeditor, you must define class = "ckeditor" -->
<Asp: textbox id = "txtcontent" class = "ckeditor" textmode = "multiline" text = '<% # BIND ("info ") %> 'runat = "server"> </ASP: textbox>

Similar to other. Net controls, setting text = '<% # BIND ("info") %>' facilitates interaction with data sources.

12, can be _ samples, _ source folder to delete, Lang directory can only retain en. JS, Zh. JS, zh-cn.js three language files.

Common troubleshooting methods:

Find the following statement in config. ascx of the ckfind Folder:

Symptom: files cannot be viewed due to security reasons. Contact the system administrator and check the ckfinder configuration file.

Statement:
Public override bool checkauthentication ()
{
Reture false;
}

Cause: If user authentication is not set or the user is not logged on, set it to Reture true (user authentication is not performed.

Symptom: Unknown error

Statement:
Public override bool checkauthentication ()
{
Reture true;
}

Cause: user authentication is not performed, but the baseurl path is incorrect.

////////////////////////////////////**** **************************************** **********////////////////////////////// ///////

On the debugging page, "a potentially dangerous request. form value was detected from the client" appears. Add

<System. Web>
<PagesValidaterequest= "False" />
System. Web>

Or the same error. Add it to the page header,

 

Or error.

Later, I finally tried to add the following line to the config. js file:

Config.html encodeoutput= True;

OK!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.