Online Training for MVC Web Designing Development, MS SQL, Digital Marketing

Ajax link example in mvc

Ajax ActionLink is very useful, one of the best way to make Ajax Call, think of situation where you want to display data based on user item click, or more information about any product when user click on link like "more info" etc.

Ajax ActionLink Example

Ajax Call Example: Click Me
@Ajax.ActionLink("Click Me", "ActionLinkExample",
new AjaxOptions
UpdateTargetId = "divContent",
InsertionMode = InsertionMode.Replace,
HttpMethod = "Post"

Now let’s look at the server side code written in controller
public JsonResult ActionLinkExample()
string result = string.Format("Ajax call made at {0}",DateTime.Now);

return Json(result);
In above action we have passed a simple string, you can pass any complex object using json

Group Training