In this article we will learn how to call action method which resides in different controller in ASP.NET MVC, first we need to pass the following parameters in ActionLink are as follows, The following code snippet can be written in view or partial view.
@Html.ActionLink("Index", "ActionName", "ControllerName", null, new { id = "OT",
style = "color: white" })
- Index is the ActionLink Name
- ActionName is the View name or ActionResult Name.
- ControllerName will be name of our controller .
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" })
I hope the preceding explanation will help you to learn how to call cross controller action methods. If you have any suggestion then drop the comment in the comment box
Post a Comment