我在 razor View MVC 中有一个菜单:
@Html.ActionLink("Criar Nova", "Create", new { tipo = Request.Params["tipo"] })
@Html.ActionLink("Listar Todas", "Index", new { tipo = @ViewBag.ENTIDADE_LISTAR_TODAS })
@Html.ActionLink("Listar Expedidoras", "Index", new { tipo = @ViewBag.ENTIDADE_LISTAR_TIPO_EXP })
@Html.ActionLink("Listar Destinatárias", "Index", new { tipo = @ViewBag.ENTIDADE_LISTAR_TIPO_DEST })
View 的 URL 如 www.xxx.com?tipo=YYY
如何根据 YYY 值在 ActionLink 文本中设置粗体等样式?
谢谢。
最佳答案
假设您知道如何去除 url 并获取您的字符串变量,您可以在 html 链接本身中使用粗体分配 css 类。
<head>
<style>
.activeMenu{font-wieght:bold;}
</style>
</head>
@Html.ActionLink("Criar Nova", "Create", new { tipo = Request.Params["tipo"] }, new { @class = "activeMenu"})
关于c# - 根据 URL 属性定义选定的菜单选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22239042/