Ajax.BeginForm with MVC 4
Using Ajax.BeginForm in your MVC View gives you an easy way of doing a partial postback via an AJAX call. In its simplest form, our view would look something like this:
The BeginForm method has several overloads which allow you to pass in the name of the Action, Controller, and many other options. See the full list of overloads here.
When the Razor syntax gets rendered as HTML, the Html.HiddenFor element will be converted into a hidden input tag:
When the form gets posted, the DepartmentId value will be included in the Person Model that is sent to the Controller.
Full Postback instead of Partial Postback with Ajax.BeginForm
If you have all of this set up and are finding that the entire page is posting back instead of a partial postback of your form, the most common problem is that the JQuery Unobtrusive Ajax script is not being included. Be sure to have this script included in your _Layout.cshtml page: