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:
<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:
<td id="ProjectFieldset">
@Html.Partial("_ProjectSelect")
</td>
_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.
Replace:
with:
Notice the typo that you have in your
jquery.unobtrusive-ajax.jsscript name.Also
jquery 1.4.4is kinda old now. I would recommend you using a more recent version.