Context: Asp.Net MVC3 w/Razor
I am trying to put a login form on a Razor layout (formerly master page) so that, when the user times out, s/he can be prompted to log
Late but correct. Make sure to reference the unobtrusive-ajax.js file as well as the MicrosoftAjax.js and MicrosoftMvcAjax.js files in that order. Works
I had the same problem and solution was:
Unfortunatelly, it will not help for you because you set UnobtrusiveJavaScriptEnabled to false, but can help for somebody.
Notice if you use Asp.Net template like I do, It bundles the file to bundles/jqueryval. So you have to add
@Scripts.Render("~/bundles/jqueryval")
to the page.
Ajax.*
helpers in ASP.NET MVC 3 use unobtrusive jquery so make sure that you have referenced the jquery.unobtrusive-ajax.js
script in your view. Also you could use FireBug to see what's happening under the scenes and why the form doesn't send an AJAX request.
Also the UpdateTargetId = "form"
seems suspicious especially when your form has the refresh
id: @id = "refresh"
. Is there some other element inside your DOM with id="form"
? Maybe you meant UpdateTargetId = "refresh"
?
Besides checking if the .js is referenced, also check if no other form tags are being rendered. In my case, I had another form tag on the master page with the default action that was causing the whole page to reload.
Note: my problem was first, i referenced wrong ajax script file jquery.validate.unobtrusive.min.js
instead of jquery.unobtrusive-ajax.js
and latest jquery version doesn't worked, only jquery-1.7.1.min.js
worked for me.
i was trying to return content after successful entry
so here is the order:
<script src="~/js/jquery-1.7.1.min.js"></script>
<script src="~/js/jquery.validate.min.js"></script>
<script src="~/js/jquery.unobtrusive-ajax.min.js"></script>
Post of Darin and Richard Everett helped. hope helps.