1. Download ckeditor and put the decompressed ckedior folder under the website directory.
URL: http://ckeditor.com/
2. Load ckeditor. js on the aspx page or master template page
<! -- The address of the ckeditor JS file can be modified. -->
<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 = 'kama'; // 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 ";
// Use "/" to define the number of rows in the toolbar and modify the position by yourself.
Config. toolbar =
[
['Source', '-', 'preview'], ['cut ', 'copy', 'paste', 'pastetext ', 'pastefromword'], ['undo ', 'redo', '-', 'Find ', 'replace', '-', 'selectall', 'removeformat'], ['numberedlist ', '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'], ['maxilize ','-', 'about']
];
};
4.
5. If an error such as request. From occurs, add validaterequest = "false" to the first line of the webpage"
BOTH: <% @ page Language = "C #" autoeventwireup = "true" validaterequest = "false" codefile = "default2.aspx. cs" inherits = "default2" %>
6. database definition: Set the field to be stored to the string type.
7. Store the pre-read code. I use an Access database.
Protected void button#click (Object sender, eventargs E)
{
String connection = "provider = Microsoft. Jet. oledb.4.0; Data Source =" + server. mappath ("~ /App_data/news. mdb ");
Oledbconnection oledb = new oledbconnection (connection );
Oledb. open ();
String mess = freetextbox1.text;
String SQL = "insert into news (newmessage) values ('" + mess + "')";
Oledbcommand cmd = new oledbcommand (SQL, oledb );
Cmd. executenonquery ();
Cmd. Dispose ();
Oledb. Close ();
Response. Redirect ("show. aspx ");
}
Protected void page_load (Object sender, eventargs E)
{
String connection = "provider = Microsoft. Jet. oledb.4.0; Data Source =" + server. mappath ("~ /App_data/news. mdb ");
Oledbconnection oledb = new oledbconnection (connection );
Oledb. open ();
String SQL = "select newmessage from news where id = 6 ";
Oledbcommand cmd = new oledbcommand (SQL, oledb );
Oledbdatareader objdatareader = cmd. executereader ();
Int sname = objdatareader. getordinal ("newmessage ");
If (objdatareader. Read ())
{
Response. Write (objdatareader [sname]);
}
}
Note: The toolbar has three styles: V2, Kama, and office2003.