Showing posts with label Active Link CSS. Show all posts
Showing posts with label Active Link CSS. Show all posts

Tuesday, 8 May 2018

Selecting the active link in MVC



Based on selection or opening of the controller action the link will select in MVC like below.




There should you need to provide the css dynamically which is based on the action. You need to create the CSS style.
.activelink {
    color: #ffffff;
    background-color: #de0301;
    border-radius: 10px;
    margin-left: 4px;
}
If you see the below code there we are checking the (ViewContext.RouteData.Values["Controller"].ToString() == "Home"