ueditor的简单配置包括上传图片,代码高亮
1.在项目目录下建UEditor(重点:建的是项目)(如果是网站的话,就另行查找配置)
2.将下载下来的.net版的文件拷贝到项目UEditor目录下
3.配置editor_config.js文件
URL = window.UEDITOR_HOME_URL || "/UEditor/";
4.将net文件夹下的ashx文件 中删除掉<%@ Assembly Src="Uploader.cs" %>
5.写Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" ValidateRequest="false" CodeBehind="Default.aspx.cs" Inherits="WebApplication7.Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <script src="UEditor/editor_config.js" type="text/javascript"></script> <script src="UEditor/editor_all.js" type="text/javascript"></script> <link href="UEditor/themes/default/ueditor.css" rel="stylesheet" type="text/css" /> </head> <body> <form id="form1" runat="server"> <asp:Label ID="Label1" runat="server"></asp:Label> <div> <textarea id="myEditor" class="myEditor" style="width:900px;margin-left:auto;margin-right:auto;">
初始值 </textarea> <script type="text/javascript"> var editor = new baidu.editor.ui.Editor(); editor.render('myEditor');
//editor.setContent("初始值");
//也可以使用<asp:TextBox... TextMode="Mutil...">
</script> </div> <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" /> </form> </body> </html>
6.Default.aspx.cs文件
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace WebApplication7 { public partial class Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { Label1.Text = HttpUtility.HtmlDecode(Request.Form["editorValue"].ToString()); } } }
7.配置web.config
<?xml version="1.0"?> <!-- 有关如何配置 ASP.NET 应用程序的详细信息,请访问 http://go.microsoft.com/fwlink/?LinkId=169433 --> <configuration> <system.web> <httpRuntime requestValidationMode="2.0" /> </system.web> </configuration>