0

I am creating an actionLink in MVC

@Html.ActionLink(item.someId, "SomeDetails", "SomeCase", new { userId = item.userId }, null)

Now i want to add color to it based on a variable i have calculated

for example if i am creating a td i am adding color to it like

<tr style="color:@currentColor">

is there a way like this to add color attribute to the actionLink that i have created? without adding @class="someClassName"

0

2 Answers 2

2

You can do it like this ,

@Html.ActionLink(item.someId, "SomeDetails", "SomeCase", new { userId = item.userId },  new { @style="color:"+currentColor })
Sign up to request clarification or add additional context in comments.

Comments

2

The fourth param you are passing null is going to take a html object. so you can pass the class or style attribute in that param

@Html.ActionLink(item.someId, "SomeDetails", "SomeCase", new { userId = item.userId }, ,  new { @style="color:"+@currentColor })

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.