<!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>
<title></title>
<script src="ckeditor/ckeditor.js" type="text/javascript"></script>
</head>
<body>
<textarea id="Textarea1" cols="20" rows="2" class="ckeditor"></textarea>
</body>
</html>
1.View代码
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>
<!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>Demo</title>
<script src="../../ckeditor/ckeditor.js" type="text/javascript"></script>
</head>
<body>
<%
using (Html.BeginForm())
{
%>
<div>
<%: Html.TextArea("editor", new Dictionary<string, object>() { { "class", "ckeditor" } })%>
</div>
<div>
<input id="submit1" type="submit" value="提交" />
</div>
<%
}
%>
</body>
</html>
2.Controller代码
public ActionResult Demo()
{
return View();
}
[HttpPost]
[ValidateInput(false)]
public ActionResult Demo(FormCollection collection)
{
string html = collection["editor"];
Response.Write(html);
return View();
}
3.注意处理Post提交的Controller头部标记 [ValidateInput(false)] ,另还需要在Web.config里配置
<system.web>
<httpRuntime requestValidationMode="2.0"/>
</system.web>
否则提交时会报异常“从客户端XXXX中检测到有潜在危险的 Request.Form 值”。