4

I'm curious, is it possible to use multiple CSS classes on an ActionLink in MVC3 Razor syntax? The line below appears to load only the first class(btn) and skipps btn_c.

@Html.ActionLink("Administration", "Index", "Admin", null, new { @class = "btn btn_c" })
1
  • That's not true. Look in Firebug. Commented Dec 11, 2011 at 15:29

2 Answers 2

2

I've just used your existing ActionLink with the following css:

.btn
{
    color: yellow;
}

.btn_c
{
    background-color: red;
}

And it successfully produced the following output:

LinkOutput

Sign up to request clarification or add additional context in comments.

1 Comment

Sorry, it was a mistake on my part, turns out I had a CSS class overriding btn_c. Has been a long day...
0

I am having this exact problem with bootstrap classes, I do not have another class overriding the bootstrap classes. In fact I verified through dev tools that I can add the "active" class to the "nav-link" class.

Here is my razor code:

@Html.ActionLink("Statement Info", "Edit", new { Controller = ViewBag.MyContoller}, new { name = "navAction", id = "Statements", @class = "nav-link active"})

When I view the element in dev tools, it only has the "nav-link" class

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.