Calling Another Controller Action Method Using ActionLink in ASP.NET MVC

This article explains how to call another controller action method using ActionLink in ASP.NET MVC. we need to pass the following parameters in ActionLink are as follows
@Html.ActionLink("Index", "ActionName", "ControllerName", null, new { id = "OT",
style = "color: white" })
In the above code
  •     Index is the ActionLink Name
  •     ActionName is the View name or ActionResult Name.
  •     ControllerName will be name of our controller .
after implementing the  in parent view entire code will be look like as follows

Parentview.Cshtml

@{
    ViewBag.Title = "Parentview";
}

<h2>Parentview</h2>
@*To call same same controller view*@
@Html.ActionLink("Index", "ActionName")

@*To call another controller view*@
@Html.ActionLink("Index", "ActionName", "ControllerName", null, new { id = "OT",
 style = "color: white" })
Summary
I hope this article is useful for all readers. If you have any suggestion then please contact me.

Post a Comment

www.CodeNirvana.in

Protected by Copyscape Online Copyright Protection
Copyright © Compile Mode