我有一个简单的ASP.Net MVC视图,其中包含一个FCKeditor文本框(使用FCKeditor的Javascript ReplaceTextArea()函数创建) . 这些包含在Ajax.BeginForm帮助器中:
<% 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操作中的testBox字符串始终为“Content”,无论FCKeditor的内容是否已更改为 . 如果第二次再次提交Ajax表单(没有进一步更改),则testBox参数正确包含FCKeditor的实际内容 .
如果我使用Html.TextArea而不替换FCKeditor它可以正常工作,如果我使用标准的Post表单提交到AJAX,所有工作都按预期工作 .
难道我做错了什么?
如果没有针对此问题的合适/直接解决方法?
1 回答
该问题与MVC无关,但是由于将FCKeditor与AJAX结合使用而引起 . 要修复上面的代码,我在提交按钮的onclick事件中添加了以下内容:
有关更多信息see here .