Using MVC3, C # and Razor View Engine: I have a form that has an Ajax Action link. In the parameters, I'm trying to specify the OnBegin and OnComplete javascript function calls. In this question, I took out the meat of the functions and simply added warnings so that I could check that the functions that get caught. What I really want to do with these functions is to use $ .blockUI for the duration of the ajax call.
The corresponding code is as follows:
@Ajax.ActionLink("my test link", "myAction", new { Controller = "myController" }, new AjaxOptions { OnBegin = "ajaxStart", OnComplete = "ajaxStop" }) <script type="text/javascript"> function ajaxStart() { alert("start"); } function ajaxStop() { alert("stop"); } </script>
For some reason, two functions are never called as indicated. I tried it with and without parentheses, for example:
@Ajax.ActionLink("my test link", "myAction", new { Controller = "myController" }, new AjaxOptions { OnBegin = "ajaxStart()", OnComplete = "ajaxStop()" })
None of them work.
Any ideas?
Thank you, Tony
source share