I have used following code to add css class:
<div id="123" class="tab-pane @{ if (some_condition) { Html.Raw("active"); }; } ">
But it did not work.
I hope for this result:
<div id="123" class="tab-pane active">
@MichaelPerrenoud's answer is close. You need to wrap the whole conditional in parenthesis.
Using @() tells razor to output a string. So
<div id="123" class='tab-pane @(condition ? "active" : "")'>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With