Reputation: 199
This is my layout page:
<!doctype html>
<html lang="en">
<head>
<meta charset='utf-8'>
<title>@ViewBag.Title</title>
</head>
<body>
@Html.ActionLink("Home", "Index", "Home", null, new { @class = "selected"})
@Html.ActionLink("Users", "Index", "User")
@Html.ActionLink("Customers", "Index", "ProductCompany")
@RenderBody()
</body>
</html>
I would like to modify actionlink "selected" class depending on the loaded view on the server side. I am looking for options available to do it.
Best regards
Upvotes: 0
Views: 273
Reputation: 33809
I think you could send the class name in the ViewBag
and set it as below;
@Html.ActionLink("Home", "Index", "Home", null, new { @class = @ViewBag.myClass})
Upvotes: 1