Premium Only Content

Part 9 Generate hyperlinks using actionlink html helper
In this video we will discuss, generating hyperlinks using actionlink html helper, for navigation between mvc pages.
Please watch Part 8, before proceeding.
We want to display all the employees in a bulletted list as shown below. Notice that all the employee names are rendered as hyperlinks.
Adding Links between pages using html helpers.png
When the hyperlink is clicked, the user will be redirected to employee details page, displaying the full details of the employee as shown below.
Generate links using Html.ActionLink html helper.png
Copy and paste the following Index() action method in EmployeeController class. This method retrieves the list of employees, which is then passed on to the view for rendering.
public ActionResult Index()
{
EmployeeContext employeeContext = new EmployeeContext();
// Replace square brackets with angular brackets
List[Employee] employees = employeeContext.Employees.ToList();
return View(employees);
}
At the moment, we don't have a view that can display the list of employees. To add the view
1. Right click on the Index() action method
2. Set
View name = Index
View engine = Razor
Select, Create a stronlgy-typed view checkbox
Select "Employee" from "Model class" dropdownlist
3. Click Add
At the point, "Index.cshtml" view should be generated. Copy and paste the following code in "Index.cshtml".
@* Replace square brackets with angular brackets *@
@model IEnumerable[MVCDemo.Models.Employee]
@using MVCDemo.Models;
[div style="font-family:Arial"]
@{
ViewBag.Title = "Employee List";
}
[h2]Employee List[/h2]
[ul]
@foreach (Employee employee in @Model)
{
[li]@Html.ActionLink(employee.Name, "Details", new { id = employee.EmployeeId })[/li]
}
[/ul]
[/div]
Points to Remember:
1. @model is set to IEnumerable[MVCDemo.Models.Employee]
2. We are using Html.ActionLink html helper to generate links
Copy and paste the following code in Details.cshtml
@Html.ActionLink("Back to List", "Index")
-
LIVE
Candace Show Podcast
1 hour agoThey Are Lying About Charlie Kirk. | Candace Ep 235
9,877 watching -
LIVE
Kim Iversen
1 hour agoWas There a Second Shooter in the Charlie Kirk Attack?
2,295 watching -
LIVE
Redacted News
2 hours ago“They’re NOT stopping with Charlie Kirk!” JD Vance TORCHES violent leftists | Redacted
10,221 watching -
39:45
Kimberly Guilfoyle
1 hour agoCharlie's Legacy and Our Mission | Ep.253
12.3K8 -
UPCOMING
Tundra Tactical
1 hour agoWhats The Deal With New Guns In 2025 Part 2
81 -
UPCOMING
The Amber May Show
3 hours agoCharlie Kirk Murder Probe EXPLODES | FBI, FEMA, & SCOTUS Shake the Nation
931 -
1:14:55
vivafrei
5 hours agoJD Vance Pays Tribute to Charlie Kirk; Ryan Routh Trial Continues! And More!
168K91 -
LIVE
Dr Disrespect
6 hours ago🔴LIVE - DR DISRESPECT - WARZONE - PROTECT THE DOC
1,156 watching -
LIVE
LFA TV
19 hours agoLFA TV ALL DAY STREAM - MONDAY 9/15/25
1,562 watching -
29:05
Athlete & Artist Show
5 hours ago1st Line Minutes at 35, Slovenian Sports Fans, and MORE
4.61K