Asp. NET in CKEditor and Ckfinder configuration Use _ Practical skills

Source: Internet
Author: User

Include CKEditor with Ckfinder in the project and add references to the assembly

Download CKEditor and Ckfinder from the Http://cksource.com website, and under the two unpacked items, the Samples folder inside is an example, it is not necessary to delete the Samples folder directly, Each has a bin directory under the CKEditor and Ckfinder directories, adding references to assemblies under the release directory in the bin directory

2. Register a user control on a page that requires a rich-text editor

Copy Code code as follows:

<%@ Register assembly= "ckeditor.net" namespace= "ckeditor.net" tagprefix= "CKEditor"%>

3. Use of CKEditor

Add a rich-text editor, just as you would with your own user control, using the CKEditor

Copy Code code as follows:

<ckeditor:ckeditorcontrol height= runat= "Server" id= "Txtnewscontent" ></CKEditor:CKEditorControl>

1. Integrated Ckfinder

Override Page's OnLoad method in the page's corresponding code page and integrate Ckfinder into CKEditor in the OnLoad method

Copy Code code as follows:

protected override void OnLoad (EventArgs e)
{
Ckfinder.filebrowser browser = new Ckfinder.filebrowser ();
integrated into the corresponding ckeditor, the parameter is the corresponding ID
Browser. Setupckeditor (txtnewscontent);
Set up directories to save uploaded files
Browser. BasePath = "~/files/";
Base. OnLoad (e);
}

2. Configure Ckfinder

Ckfinder is a no refresh upload tool, for upload, there should be strict control of the rights, control mainly from two aspects: first, can not be uploaded to anyone, only authorized personnel can upload, second, can not be any file upload, to upload the file to control, You cannot have the user upload the executable file to the server to control the file type.

Open the Ckfinder directory of the Config.ascx, the first method is to verify the authorization, see whether the user has permission to upload files, you can verify the session, verify the user is authorized, the default is return FALSE, if not modified, direct use in the upload will be an error, No authorization cannot be uploaded if the test phase can be changed directly to return true; However, it is best to verify the permissions, not directly return true (I am here to verify that the user is logged in, if the login returns True, or false)

Continue to look down at the Setconfig () method set up some of the upload file configuration, such as the path to upload files saved, upload file type restrictions, etc., if you need to set the style you need to modify the Config.js file

The above mentioned is the entire content of this article, I hope you can enjoy

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.