这是我的布局页面:
<!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>
我想修改actionlink "selected"类取决于服务器端加载的视图。我正在寻找可用的选项来做到这一点。
我认为你可以在ViewBag
中发送类名,并设置如下;
@Html.ActionLink("Home", "Index", "Home", null, new { @class = @ViewBag.myClass})