开发者

ASP.NET MVC View Profile

开发者 https://www.devze.com 2022-12-19 20:49 出处:网络
I have an Html.Actionlink to which I am trying to add a \"class\" and an ActiveClass. <%= Html.ActionLink(\"Home\", \"Home\", \"Acco开发者_运维问答unt\", null,

I have an Html.Actionlink to which I am trying to add a "class" and an ActiveClass.

<%= Html.ActionLink("Home", "Home", "Acco开发者_运维问答unt", null, 
    new {@class ="some-class"}, 
    Html.RenderLinkClassIfActive("Home", "Account", "active"))  %>

However, this doesn't work. What can I differently to make this work?


Could you add the RenderLinkClassIfActive code please?

UPDATE: Supposing Html.RenderLinkClassIfActive("Home", "Account", "active") returns a class if active try:

<%= Html.ActionLink("Home", "Home", "Account", null, new {@class ="some-class " + Html.RenderLinkClassIfActive("Home", "Account", "active") } )%>
0

精彩评论

暂无评论...
验证码 换一张
取 消