I tried to submit my form with a button and everything worked (the controller was call and the POST worked fine). Then I add a checkbox right next to it, and it returns a blank page with only the checkbox on it when I click it. Im using:
我尝试用按钮提交我的表单,一切正常(控制器是通话,POST工作正常)。然后我在它旁边添加一个复选框,当我点击它时,它会返回一个空白页面,上面只有复选框。我在用着:
<script src="@Url.Content("~/Scripts/jquery-1.4.4.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.unobtrusiveajax.js")"type="text/javascript"></script>
Part of my views (im using partial view):
Index.cshtml:
我的部分观点(我使用局部视图):Index.cshtml:
<td id="ProjectFieldset">
@Html.Partial("_ProjectSelect")
</td>
_ProjectSelect.cshtml :
_ProjectSelect.cshtml:
@using (Ajax.BeginForm("test", "Project", new AjaxOptions() { InsertionMode = InsertionMode.Replace, UpdateTargetId = "ProjectFieldset" }))
{
<td>
@Html.CheckBox("ckboxItem", true , new {onchange="this.form.submit();"})
<input type="submit" value="allo" id="allo" />
</td>
}
Controller:
控制器:
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult test(bool ckboxItem)
{
ViewData["projects"] = db.Projects;
return PartialView("_ProjectSelect");
}
This is just a part of my code. There is no HTML error. So, the checkbox and the button are well displayed, and when press the button, everything works. When I click the checkbox, it goes in the controller, but after that, it display a blank page. Any help here ??? Thks.
这只是我代码的一部分。没有HTML错误。因此,复选框和按钮显示良好,按下按钮时,一切正常。当我单击该复选框时,它会进入控制器,但之后会显示一个空白页面。这里有什么帮助??? THKS。
1 个解决方案
#1
1
Replace:
更换:
<script src="@Url.Content("~/Scripts/jquery.unobtrusiveajax.js")"type="text/javascript"></script>
with:
有:
<script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.js")"type="text/javascript"></script>
Notice the typo that you have in your jquery.unobtrusive-ajax.js
script name.
请注意jquery.unobtrusive-ajax.js脚本名称中的拼写错误。
Also jquery 1.4.4
is kinda old now. I would recommend you using a more recent version.
jquery 1.4.4现在还有点老了。我建议你使用更新的版本。
#1
1
Replace:
更换:
<script src="@Url.Content("~/Scripts/jquery.unobtrusiveajax.js")"type="text/javascript"></script>
with:
有:
<script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.js")"type="text/javascript"></script>
Notice the typo that you have in your jquery.unobtrusive-ajax.js
script name.
请注意jquery.unobtrusive-ajax.js脚本名称中的拼写错误。
Also jquery 1.4.4
is kinda old now. I would recommend you using a more recent version.
jquery 1.4.4现在还有点老了。我建议你使用更新的版本。