30 Mar 2017

Adding dynamic CSS to List Item using MVC

Hi,

In this post I have explained
how to add dynamic css styles to list menu using MVC. Here controller name is "Home" and action name is "Index".
If user select this action then we are applying class "selected" to the list item.

<li @(ViewContext.RouteData.Values["actioin"].ToString().Equals("Index")
&& ViewContext.RouteData.Values["controller"].TOString().Equals("Home") ? "class=selected" : "")>

<a href="@Url.Action("Index" , "Home")"> home<a/>

</li>

No comments:

Post a Comment