I\'m creating a new project, asp.net mvc3 with Razor, and wanting to turn the LogOn into an ajax request.
HTML
@using (Ajax.BeginForm(\"LogOn\", \"Ac
That's because by default ASP.NET MVC 3 uses jQuery and unobtrusive AJAX instead of the MicrosoftAjax* library. This means that when you write Ajax.BeginForm
you will need to include the proper scripts inside your page:
<script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.js")" type="text/javascript"></script>
and in your web.config make sure that you have unobtrusive javascript enabled:
<add key="UnobtrusiveJavaScriptEnabled" value="true"/>
Now you can safely throw away all MicrosoftAjax*
script references on your page if you had any, they are no longer used.
This being said personally I never used any of the Ajax.*
helpers. I always prefer to have control. So I would write:
@using (Html.BeginForm("LogOn", "Account"))
{
}
and then AJAXify this form using the jquery form plugin:
$(function() {
$('form').ajaxForm(function(result) {
alert('form successfully submitted');
});
});