This is my Test.cshtml:
@using(Ajax.BeginForm("Test", new AjaxOptions()))
{
<p>
Some String: <input name="someString" type="text" />
</p>
<button type="submit">Submit</button>
}
Where jquery-1.4.4.min.js is included by the layout.
My Controller has the following two actions:
public ActionResult Test()
{
return View();
}
[HttpPost]
public ActionResult Test(string someString)
{
if (Request.IsAjaxRequest())
return Json("Okey-dokey");
return View();
}
It seems that when I hit submit, it always does a full post-back, Request.IsAjaxRequest() is never true!
What gives?
George,
Please make sure that you include the script jquery.unobtrusive-ajax.js in your layout page.
counsellorben