1.先从
http://ueditor.baidu.com/website/download.html下载UEditor
(最新版本使用的是.net4.0的环境,并且必须是应用程序。详情可以查看
http://fex-team.github.io/ueditor/#server-net
)
2.将压缩包解压到web项目下
3.在需要使用UEditor页面添加如下代码
4.添加完成后就可以在id为container的标签中间写入你的初始化内容<!-- 加载编辑器的容器 -->
<script id="container" name="content" type="text/plain">
这里写你的初始化内容
</script>
<!-- 配置文件 -->
<script type="text/javascript" src="/ueditor/ueditor.config.js"></script>
<!-- 编辑器源码文件 -->
<script type="text/javascript" src="/ueditor/ueditor.all.js"></script>
<script type="text/javascript" charset="utf-8" src="/ueditor/lang/zh-cn/zh-cn.js"></script>
<!-- 实例化编辑器 -->
<script type="text/javascript">
var ue = UE.getEditor('container');
</script>
5.在UEditor/net/config.json中配置文件上传目录,图片默认目录为
UEditor/net/upload/image
6.使用ue.getPlainTxt()方法可以获取到编辑器中的内容。具体其他方法可以查看
http://fex-team.github.io/ueditor/#api-common
7.可以通过ajax保存到数据库,如果不通过ajax保存可能会报“
从客户端(content="<p> &nb...")中检测到有潜在危险的 Request.Form 值。
”这种错误,解决方法:在web.config文件中加入
这段代码就可以了。<pages validateRequest="false"/>
<httpRuntime requestValidationMode="2.0"/>