First of all, where is the documentation for Ajax.*
methods in asp.net mvc?
Can Ajax.ActionLink
be used to call an action, get a partial view, open a modal window and put the content in it?
First of all, where is the documentation for Ajax.*
methods in asp.net mvc?
Can Ajax.ActionLink
be used to call an action, get a partial view, open a modal window and put the content in it?
For me this worked after I downloaded AJAX Unobtrusive library via NuGet :
Than add in the view the references to jquery and AJAX Unobtrusive:
@Ajax.ActionLink requires jQuery AJAX Unobtrusive library. You can download it via nuget:
Then add this code to your View:
Sure, a very similar question was asked before. Set the controller for ajax requests:
Set the action link as wanted:
Note that I'm using Razor view engine, and that your AjaxOptions may vary depending on what you want. Finally display it on a modal window. The jQuery UI dialog is suggested.
Ajax.ActionLink only sends an ajax request to the server. What happens ahead really depends upon type of data returned and what your client side script does with it. You may send a partial view for ajax call or json, xml etc. Ajax.ActionLink however have different callbacks and parameters that allow you to write js code on different events. You can do something before request is sent or
onComplete
. similarly you have an onSuccess callback. This is where you put your JS code for manipulating result returned by server. You may simply put it back in UpdateTargetID or you can do fancy stuff with this result using jQuery or some other JS library.