CKEditor使用说明
<tr>
<th width="15%">
正文:
</th>
<td colspan="3">
<asp:TextBox ID="txtContent" Name="Content" runat="server" CssClass="ckeditor" TextMode="MultiLine"
Rows="25" Columns="50" validator="required,length[1,200]" />
</td>
</tr>
CKEditor是一个用于网页中的文本编辑器。这是一个所见即所得的编辑器,这就意味着,用户编辑的文本与用户发布的文本结果基本相似。
它类似我们常用的网页编辑器,像微软Word和OpenOffice等的桌面应用程序。
CKEditor精简
CKEditor下面的_Sample和_source文件夹可以删除,分别是示例文件夹和未压缩的源程序。
lang文件夹中是语言文件,可以删除所有你不需要的文件,比如:只保留"zh-cn.js 等"。
删除根目录下的changes.html(更新列表),install.html(安装指南),license。html(使用许可)。
删除skins目录下不需要的皮肤。(建议在config.js中指定皮肤样式)
CKEditor的核心文件是:ckeditor.js调用需要加载。
CKEditor的配置文件是:config.js 所有参数配置都在此设置
表情符号:plugins/smiley/images
CKeditor的应用(.net环境)
1、引入脚本js
<script type="text/javascript" src="ckeditor/ckeditor.js"></script>路径需要根据自己的文件做相应修改。
2、
<asp:TextBox ID="txtContent" CssClass="ckeditor" runat="server" Text="" TextMode="MultiLine" Rows="25" Columns="50" />
设置你的TextBox的CssClass属性为ckeditor,如上示例
另外,如下方法也可以的
<asp:TextBox ID="TextBox1" runat="server" Rows="10" TextMode="MultiLine"></asp:TextBox>
<script type="text/javascript">CKEDITOR.replace('TextBox1')</script> 其中 replace中的TextBox1是<asp:textbox的ID。
ckeditor的配置(配置文件:config.js)
示例:
CKEDITOR.editorConfig = function( config )
{
// Define changes to default configuration here. For example:
// config.language = 'fr';
// config.uiColor = '#AADC6E';
config.language='zh-cn';//中文
config.skin='v2';
config.resize_enabled = false;
config.width=800;
config.height=600;
};
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
CKEditor 3 JavaScript API Documentation :
http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.config.htm
一、使用方法:
1、在页面<head>中引入ckeditor核心文件ckeditor.js
<script type="text/javas cript" src="ckeditor/ckeditor.js"></script>
2、在使用编辑器的地方插入HTML控件<textarea>
<textarea id="TextArea1" cols="20" rows="2" class="ckeditor"></textarea>
如果是ASP.NET环境,也可用服务器端控件<TextBox>
<asp:TextBox ID="tbContent" runat="server" TextMode="MultiLine" class="ckeditor"></asp:TextBox>
注意在控件中加上 class="ckeditor" 。
3、将相应的控件替换成编辑器代码
<script type="text/javas cript">
CKEDITOR.replace('TextArea1');
//如果是在ASP.NET环境下用的服务器端控件<TextBox>
CKEDITOR.replace('tbContent');
如果<asp:TextBox ID="tbContent" runat="server" TextMode="MultiLine" CssClass="ckeditor"></asp:TextBox>中是服务器端的class名就可以省去
CKEDITOR.replace('tbContent');
//如果<TextBox>控件在母版页中,要这样写
CKEDITOR.replace('<%=tbContent.ClientID.Replace("_","$") %>');
</script>

浙公网安备 33010602011771号