Use of FCKeditor in. net

Source: Internet
Author: User
Tags connectionstrings

Use of the ASP. NET FCKeditor Text Editor]
: Http://www.fckeditor.net/download

Use FCKeditor

I. Configuration
1. Click downloadat http://www.fckeditor.net/to download fckeditor_2.5.1.zipand fckeditor.net (ASP. NET control to easily integrate FCKeditor on. NET web pages .)

2. Create a project, such as fck. Decompress fckeditor_2.5.1.zip, which contains the FCKeditor directory. Copy the entire directory to the root directory of the newly created ASP. NET project. Open fckconfig. js in the FCKeditor directory and modify the following two items:
Fckconfig. defaultlanguage = 'en ';
Change
Fckconfig. defaultlanguage = 'zh-cn ';
-----------------------------------------------------
VaR _ filebrowserlanguage = 'php'; // ASP | aspx | CFM | lasso | Perl | PHP | py
VaR _ quickuploadlanguage = 'php'; // ASP | aspx | CFM | lasso | Perl | PHP | py
Change
VaR _ filebrowserlanguage = 'aspx '; // ASP | aspx | CFM | lasso | Perl | PHP | py
VaR _ quickuploadlanguage = 'aspx '; // ASP | aspx | CFM | lasso | Perl | PHP | py

3. Create a new tab named FCKeditor in the toolbox of vs05/08, right-click it, select Choose item, and locate decompressed FCKeditor. fckeditor2.51 \ FCKeditor. fredck in the net_2.5 \ bin \ release \ 2.0 directory. fckeditorv2.dll. A FCKeditor. NET component is generated under this tab. Drag and Drop the component to the interface in the design mode of. Click this component and set bashpath to/fck/FCKeditor/on the property panel. Note that the fck here is the ASP you created.. Net project name. FCKeditor is the directory name under the project root directory. (Note: The slash between/fck/FCKeditor/and the front and back will not be displayed if one is missing ). CTRL + F5!

Other secondary configurations (do not affect usage ):
* You can delete all examples and source files starting with the "FCKeditor" directory and Its subdirectories.
* You can retain only fckconfig. JS, FCKeditor. JS, and several XML files in the FCKeditor directory, and delete all the other files.
* The editor directory under the FCKeditor directory has a filemanager directory, which deletes all directories except the aspx directory in the borswer \ Default \ connectors directory.
* You can delete all the contents except zh-cn.js, en. js and Zh. js under the editor \ Lang directory.

Ii. upload images
FCKeditor supports Image Upload. You can add a directory named uploadfiles under the root directory of the ASP. NET project.
In the appsettings section of Web. config
<Deleetask>
<Add key = "FCKeditor: basepath" value = "/fck/FCKeditor"/>
<Add key = "FCKeditor: userfilespath" value = "/fck/uploadfiles/"/>
</Appsettings>

Note: userfielspath./fck/uploadfiles/specifies the directory to be uploaded. I personally think that the fck here can be considered as the virtual directory name on the server. (In addition, it is found that it does not work if it is set up for a long time ).

When uploading an image, you may encounter "this connector is disabled please check the" Editor/filemanager/connectors/aspx/config. aspx error. You can change FCKeditor \ editor \ filemanager \ connectors \ aspx \ config. the checkauthentication () method of ascx. True is returned.

3. Simple FCKeditor database access and display
1. Add a new SQL Server database in the project, and keep the file name as database. MDF. Create a new mytable table with only two fields. One is the primary key automatically added to the int type, and the other is the mycontent of the text type. We need to store the fckeditor1.value value in this field.

2. Create a display page first. Add show. aspx to the project, drag a sqldatasource, and set the returned mytable content. Use repeater.

// Code

<Asp: repeater id = "myrepeater" runat = "server" performanceid = "sqlperformance1">
<Headertemplate>
<Table>
</Headertemplate>
<Itemtemplate>
<Tr>
<TD>
<% # Eval ("mycontent") %>
</TD>
</Tr>
</Itemtemplate>
<Footertemplate>
</Table>
</Footertemplate>
</ASP: repeater>
<Asp: sqldatasource id = "sqldatasource1" runat = "server"
Connectionstring = "<% nbsp; connectionstrings: connectionstring %>"
Selectcommand = "select [OID], [mycontent] from [mytable] Order by [OID] DESC"> </ASP: sqldatasource>

3. store data in the database
Reference System. configuration in the project (to use system. Web. webconfigurationmanager)
Enter a button on the FCKeditor interface, and then
Protected void button#click (Object sender, eventargs E)
{
Using (sqlconnection conn = new sqlconnection ())
{
Conn. connectionstring = system. Web. configuration. webconfigurationmanager. connectionstrings ["connectionstring"]. connectionstring;
Sqlcommand cmd = new sqlcommand ();
Cmd. Connection = conn;
Cmd. commandtext = "insert into mytable (mycontent) values (@ fckcontent )";
Cmd. Parameters. addwithvalue ("fckcontent", fckeditor1.value );
Conn. open ();
Cmd. executenonquery ();
}
}

Customize the FCKeditor Toolbar

Modify the fckconfig. js script in the FCKeditor directory

Fckconfig. toolbarsets ["default"] = [... ... Customization

The toolbarset of the control specifies which toolbar is set... Default

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.