我有一个简单的ASP.NET MVC视图,其中包含一个fckeditor文本框(使用fckeditor的javascript replaceTextArea()函数创建)。这些都包含在ajax.begininform帮助程序中:
<% using (Ajax.BeginForm("AddText", "Letters",
new AjaxOptions() { UpdateTargetId = "addTextResult" }))
{%>
<div>
<input type="submit" value="Save" />
</div>
<div>
<%=Html.TextArea("testBox", "Content", new { @name = "testBox" })%>
<script type=""text/javascript"">
window.onload = function()
{
var oFCKeditor = new FCKeditor('testBox') ;
var sBasePath = '<%= Url.Content("~/Content/FCKeditor/") %>';
oFCKeditor.BasePath = sBasePath;
oFCKeditor.ToolbarSet = "Basic";
oFCKeditor.Height = 400;
oFCKeditor.ReplaceTextarea() ;
}
</script>
<div id="addTextResult">
</div>
<%} %>
控制器动作如下:
[ValidateInput(false)]
public ActionResult AddText(string testBox)
{
return Content(testBox);
}
在最初提交Ajax表单时,addText操作中的测试框字符串始终是“content”,不管fckeditor的内容已更改为什么。如果第二次再次提交Ajax表单(无需进一步更改),则测试框参数将正确包含fckeditor的实际内容。
如果我使用html.textfarea而不替换为fckeditor,那么它可以正常工作;如果我使用标准的post表单,那么submit代替ajax,那么一切都可以正常工作。
我做错什么了吗?
如果没有,是否有合适的/直接的解决方案来解决这个问题?